Spaces:
Sleeping
Sleeping
Commit Β·
113a06f
1
Parent(s): 5a95121
fix3: torch.load
Browse files
app.py
CHANGED
|
@@ -17,6 +17,10 @@
|
|
| 17 |
# ultralytics (for YOLOv8m-seg inference)
|
| 18 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 19 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 20 |
# ββ Python 3.13 audioop shim (removed from stdlib, needed by pydub/gradio) βββ
|
| 21 |
import sys, types
|
| 22 |
if "audioop" not in sys.modules:
|
|
@@ -811,9 +815,9 @@ def run_yolo_seg(frame_rgb: np.ndarray, seg_conf: float) -> np.ndarray:
|
|
| 811 |
n_written += int(binary.sum())
|
| 812 |
|
| 813 |
detected_cls = [_YOLO_CLASS_NAMES[min(int(c) + 1, 25)] for c in cls_ids]
|
| 814 |
-
print(f"
|
| 815 |
f"vessel px: {n_written} ({100 * n_written / (h * w):.1f}%)")
|
| 816 |
-
print(f"seg_map unique labels: {np.unique(seg_map)}")
|
| 817 |
return seg_map
|
| 818 |
|
| 819 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
@@ -1350,7 +1354,7 @@ def analyse(video_path, sten_conf, seg_conf, px_per_mm_override, progress=gr.Pro
|
|
| 1350 |
det["overlap"]=float(binary_mask[y1:y2,x1:x2].sum())/max(area,1)
|
| 1351 |
|
| 1352 |
# Step 3b β YOLOv8m-seg 26-class segmentation
|
| 1353 |
-
progress(0.65, desc="Running seg
|
| 1354 |
seg_map = run_yolo_seg(frame_rgb, seg_conf)
|
| 1355 |
seg_overlay = render_nnunet_overlay(frame_rgb, seg_map)
|
| 1356 |
|
|
@@ -1510,8 +1514,8 @@ with gr.Blocks(css=CSS, title="Angio AI") as demo:
|
|
| 1510 |
)
|
| 1511 |
seg_conf = gr.Slider(
|
| 1512 |
minimum=0.05, maximum=0.95, value=0.25, step=0.05,
|
| 1513 |
-
label="Segmentation confidence threshold",
|
| 1514 |
-
info="Detections below this confidence are discarded by NMS",
|
| 1515 |
)
|
| 1516 |
px_per_mm = gr.Slider(
|
| 1517 |
minimum=2.0, maximum=6.0, value=3.75, step=0.25,
|
|
@@ -1528,7 +1532,7 @@ with gr.Blocks(css=CSS, title="Angio AI") as demo:
|
|
| 1528 |
<ol style="font-size:13px;color:#1a2533;line-height:1.9;padding-left:16px">
|
| 1529 |
<li>Best frame extracted from video</li>
|
| 1530 |
<li>Stenosis detection β Mask2Former</li>
|
| 1531 |
-
<li>Coronary segmentation β 26-
|
| 1532 |
<li>Binary vessel mask β ResUNet</li>
|
| 1533 |
<li>FFR estimation β QFR v4</li>
|
| 1534 |
<li>SYNTAX score computation</li>
|
|
|
|
| 17 |
# ultralytics (for YOLOv8m-seg inference)
|
| 18 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
| 19 |
|
| 20 |
+
# ββ Force PyTorch weights_only=False globally (must be before any imports) βββ
|
| 21 |
+
import os as _os
|
| 22 |
+
_os.environ["TORCH_FORCE_WEIGHTS_ONLY_LOAD"] = "0"
|
| 23 |
+
|
| 24 |
# ββ Python 3.13 audioop shim (removed from stdlib, needed by pydub/gradio) βββ
|
| 25 |
import sys, types
|
| 26 |
if "audioop" not in sys.modules:
|
|
|
|
| 815 |
n_written += int(binary.sum())
|
| 816 |
|
| 817 |
detected_cls = [_YOLO_CLASS_NAMES[min(int(c) + 1, 25)] for c in cls_ids]
|
| 818 |
+
print(f"[YOLO] Detections: {len(cls_ids)} | classes: {detected_cls} | "
|
| 819 |
f"vessel px: {n_written} ({100 * n_written / (h * w):.1f}%)")
|
| 820 |
+
print(f"[YOLO] seg_map unique labels: {np.unique(seg_map)}")
|
| 821 |
return seg_map
|
| 822 |
|
| 823 |
# βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
|
|
|
| 1354 |
det["overlap"]=float(binary_mask[y1:y2,x1:x2].sum())/max(area,1)
|
| 1355 |
|
| 1356 |
# Step 3b β YOLOv8m-seg 26-class segmentation
|
| 1357 |
+
progress(0.65, desc="Running YOLOv8m-segβ¦")
|
| 1358 |
seg_map = run_yolo_seg(frame_rgb, seg_conf)
|
| 1359 |
seg_overlay = render_nnunet_overlay(frame_rgb, seg_map)
|
| 1360 |
|
|
|
|
| 1514 |
)
|
| 1515 |
seg_conf = gr.Slider(
|
| 1516 |
minimum=0.05, maximum=0.95, value=0.25, step=0.05,
|
| 1517 |
+
label="Segmentation confidence threshold (YOLOv8m-seg)",
|
| 1518 |
+
info="Detections below this confidence are discarded by YOLO NMS",
|
| 1519 |
)
|
| 1520 |
px_per_mm = gr.Slider(
|
| 1521 |
minimum=2.0, maximum=6.0, value=3.75, step=0.25,
|
|
|
|
| 1532 |
<ol style="font-size:13px;color:#1a2533;line-height:1.9;padding-left:16px">
|
| 1533 |
<li>Best frame extracted from video</li>
|
| 1534 |
<li>Stenosis detection β Mask2Former</li>
|
| 1535 |
+
<li>Coronary segmentation β 26-class</li>
|
| 1536 |
<li>Binary vessel mask β ResUNet</li>
|
| 1537 |
<li>FFR estimation β QFR v4</li>
|
| 1538 |
<li>SYNTAX score computation</li>
|