Enferlain commited on
Commit
fd3ac75
·
verified ·
1 Parent(s): 08e5dac

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -2
app.py CHANGED
@@ -189,7 +189,8 @@ model_manager = ModelManager(MODEL_CATALOG)
189
 
190
  # --- Prediction Function (v3 from before) ---
191
  def predict_anatomy_v3(image: Image.Image, model_name: str):
192
- if image is None: return {"Error": "No image provided"}
 
193
  try:
194
  model_manager.load_model(model_name)
195
  pil_image = image.convert("RGB")
@@ -245,7 +246,12 @@ def predict_anatomy_v3(image: Image.Image, model_name: str):
245
  return output_probs
246
  except Exception as e:
247
  print(f"Error during prediction: {e}\n{traceback.format_exc()}")
248
- return {"Error": str(e)}
 
 
 
 
 
249
 
250
  # --- Gradio Interface ---
251
  DESCRIPTION = """
 
189
 
190
  # --- Prediction Function (v3 from before) ---
191
  def predict_anatomy_v3(image: Image.Image, model_name: str):
192
+ if image is None:
193
+ return {"Error": 1.0, "Info": 0.0} # Return numeric values
194
  try:
195
  model_manager.load_model(model_name)
196
  pil_image = image.convert("RGB")
 
246
  return output_probs
247
  except Exception as e:
248
  print(f"Error during prediction: {e}\n{traceback.format_exc()}")
249
+ # Return properly formatted error for Gradio Label
250
+ error_msg = str(e)[:50] + "..." if len(str(e)) > 50 else str(e)
251
+ return {
252
+ f"Error: {error_msg}": 1.0,
253
+ "Please check logs": 0.0
254
+ }
255
 
256
  # --- Gradio Interface ---
257
  DESCRIPTION = """