Upload app.py with huggingface_hub
Browse files
app.py
CHANGED
|
@@ -229,19 +229,18 @@ def _predict_text(text):
|
|
| 229 |
import traceback as tb
|
| 230 |
try:
|
| 231 |
m = ensure_model()
|
| 232 |
-
print(f"Model type: {type(m)}")
|
| 233 |
|
| 234 |
-
|
|
|
|
|
|
|
| 235 |
f.write(text)
|
| 236 |
-
path = f.name
|
| 237 |
|
| 238 |
-
print(f"
|
| 239 |
df = m.get_events_dataframe(text_path=path)
|
| 240 |
-
print(f"Events: {len(df)} rows
|
| 241 |
|
| 242 |
-
print("Running prediction...")
|
| 243 |
preds, segs = m.predict(events=df)
|
| 244 |
-
print(f"Predictions
|
| 245 |
|
| 246 |
os.unlink(path)
|
| 247 |
torch.cuda.empty_cache()
|
|
|
|
| 229 |
import traceback as tb
|
| 230 |
try:
|
| 231 |
m = ensure_model()
|
|
|
|
| 232 |
|
| 233 |
+
# Create temp file INSIDE GPU worker (its own filesystem)
|
| 234 |
+
path = os.path.join(tempfile.gettempdir(), "tribe_input.txt")
|
| 235 |
+
with open(path, "w", encoding="utf-8") as f:
|
| 236 |
f.write(text)
|
|
|
|
| 237 |
|
| 238 |
+
print(f"Text written to {path} ({len(text)} chars)")
|
| 239 |
df = m.get_events_dataframe(text_path=path)
|
| 240 |
+
print(f"Events: {len(df)} rows")
|
| 241 |
|
|
|
|
| 242 |
preds, segs = m.predict(events=df)
|
| 243 |
+
print(f"Predictions shape: {preds.shape if hasattr(preds, 'shape') else type(preds)}")
|
| 244 |
|
| 245 |
os.unlink(path)
|
| 246 |
torch.cuda.empty_cache()
|