somebeast commited on
Commit
781f947
·
verified ·
1 Parent(s): 3a0ce34

Upload app.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. app.py +6 -7
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
- with tempfile.NamedTemporaryFile(mode="w", suffix=".txt", delete=False, encoding="utf-8") as f:
 
 
235
  f.write(text)
236
- path = f.name
237
 
238
- print(f"Getting events from text ({len(text)} chars)...")
239
  df = m.get_events_dataframe(text_path=path)
240
- print(f"Events: {len(df)} rows, columns: {list(df.columns)}")
241
 
242
- print("Running prediction...")
243
  preds, segs = m.predict(events=df)
244
- print(f"Predictions: {type(preds)}, shape: {preds.shape if hasattr(preds, 'shape') else 'N/A'}")
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()