Spaces:
Sleeping
Sleeping
chore(ui): temporarily disable MedSAM overlay to prevent page crashes
Browse files
app.py
CHANGED
@@ -576,8 +576,10 @@ def analyze(image):
|
|
576 |
log("analyze: chart classification error")
|
577 |
traceback.print_exc()
|
578 |
|
579 |
-
|
580 |
-
|
|
|
|
|
581 |
try:
|
582 |
np_img = np.array(image.convert("RGB"))[:, :, ::-1]
|
583 |
element_result = inference_detector(element_model, np_img)
|
@@ -595,9 +597,11 @@ def analyze(image):
|
|
595 |
except Exception:
|
596 |
log("analyze: element detection error")
|
597 |
traceback.print_exc()
|
|
|
|
|
598 |
|
599 |
-
# Datapoint Segmentation
|
600 |
-
if datapoint_model is not None:
|
601 |
try:
|
602 |
np_img = np.array(image.convert("RGB"))[:, :, ::-1]
|
603 |
datapoint_result = inference_detector(datapoint_model, np_img)
|
@@ -615,6 +619,8 @@ def analyze(image):
|
|
615 |
except Exception:
|
616 |
log("analyze: datapoint segmentation error")
|
617 |
traceback.print_exc()
|
|
|
|
|
618 |
|
619 |
# MedSAM availability info
|
620 |
try:
|
@@ -685,9 +691,9 @@ def analyze_with_medsam(base_result, image):
|
|
685 |
}
|
686 |
log(f"analyze_with_medsam: segments={len(segmentations)}")
|
687 |
|
688 |
-
|
689 |
-
log("analyze_with_medsam: end")
|
690 |
-
return base_result,
|
691 |
except Exception:
|
692 |
log("analyze_with_medsam: fatal error")
|
693 |
traceback.print_exc()
|
|
|
576 |
log("analyze: chart classification error")
|
577 |
traceback.print_exc()
|
578 |
|
579 |
+
is_medical = str(result.get("chart_type_label", "")).strip().lower() == "medical image"
|
580 |
+
|
581 |
+
# Element Detection (skip for medical images)
|
582 |
+
if element_model is not None and not is_medical:
|
583 |
try:
|
584 |
np_img = np.array(image.convert("RGB"))[:, :, ::-1]
|
585 |
element_result = inference_detector(element_model, np_img)
|
|
|
597 |
except Exception:
|
598 |
log("analyze: element detection error")
|
599 |
traceback.print_exc()
|
600 |
+
elif is_medical:
|
601 |
+
result["element_result"] = "skipped for medical image"
|
602 |
|
603 |
+
# Datapoint Segmentation (skip for medical images)
|
604 |
+
if datapoint_model is not None and not is_medical:
|
605 |
try:
|
606 |
np_img = np.array(image.convert("RGB"))[:, :, ::-1]
|
607 |
datapoint_result = inference_detector(datapoint_model, np_img)
|
|
|
619 |
except Exception:
|
620 |
log("analyze: datapoint segmentation error")
|
621 |
traceback.print_exc()
|
622 |
+
elif is_medical:
|
623 |
+
result["datapoint_result"] = "skipped for medical image"
|
624 |
|
625 |
# MedSAM availability info
|
626 |
try:
|
|
|
691 |
}
|
692 |
log(f"analyze_with_medsam: segments={len(segmentations)}")
|
693 |
|
694 |
+
# Overlay disabled for stability
|
695 |
+
log("analyze_with_medsam: end (overlay disabled)")
|
696 |
+
return base_result, None
|
697 |
except Exception:
|
698 |
log("analyze_with_medsam: fatal error")
|
699 |
traceback.print_exc()
|