Siddharth Ravikumar commited on
Commit
de82703
·
1 Parent(s): 87c0e77

fix: save inference errors to DB to display in UI

Browse files
Files changed (1) hide show
  1. app.py +8 -1
app.py CHANGED
@@ -263,7 +263,14 @@ def run_analysis_fn(case_id, progress=gr.Progress()):
263
  ))
264
  analysis_results.append({"filename": photo["filename"], "analysis": raw, "time_ms": round(elapsed_ms)})
265
  except Exception as e:
266
- analysis_results.append({"filename": photo["filename"], "analysis": f"Error: {e}", "time_ms": 0})
 
 
 
 
 
 
 
267
 
268
  # Identify parties
269
  progress(0.55, desc="Identifying parties...")
 
263
  ))
264
  analysis_results.append({"filename": photo["filename"], "analysis": raw, "time_ms": round(elapsed_ms)})
265
  except Exception as e:
266
+ err_msg = f"Error: {e}"
267
+ run_async(db.add_scene_analysis(
268
+ photo_id=photo["id"],
269
+ raw_analysis=err_msg,
270
+ model_id=settings.model_id,
271
+ inference_time_ms=0,
272
+ ))
273
+ analysis_results.append({"filename": photo["filename"], "analysis": err_msg, "time_ms": 0})
274
 
275
  # Identify parties
276
  progress(0.55, desc="Identifying parties...")