MuhammadAdil63 commited on
Commit
c6eb6a7
Β·
1 Parent(s): 0d5624a

fix: torch.load

Browse files
Files changed (1) hide show
  1. app.py +27 -5
app.py CHANGED
@@ -24,6 +24,30 @@ if "audioop" not in sys.modules:
24
  if "pyaudioop" not in sys.modules:
25
  sys.modules["pyaudioop"] = types.ModuleType("pyaudioop")
26
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  import os
28
  import sys
29
  import json
@@ -701,11 +725,9 @@ def _load_yolo():
701
  f"Check HF_TOKEN secret and repo MuhammadAdil63/angio-ai-checkpoints"
702
  )
703
  print(f"[YOLO] Loading checkpoint: {ckpt}")
704
- # PyTorch 2.6+ requires explicit allowlisting of custom globals
705
  try:
706
  import torch.serialization
707
  from ultralytics.nn.tasks import SegmentationModel
708
- from ultralytics.nn.modules import (Conv, C2f, SPPF, Detect, Segment)
709
  torch.serialization.add_safe_globals([SegmentationModel])
710
  except Exception as _e:
711
  print(f"[YOLO] safe_globals warning: {_e}")
@@ -1494,7 +1516,7 @@ with gr.Blocks(css=CSS, title="Angio AI") as demo:
1494
  <ol style="font-size:13px;color:#1a2533;line-height:1.9;padding-left:16px">
1495
  <li>Best frame extracted from video</li>
1496
  <li>Stenosis detection β€” Mask2Former</li>
1497
- <li>Coronary segmentation β€” (26-classes)</li>
1498
  <li>Binary vessel mask β€” ResUNet</li>
1499
  <li>FFR estimation β€” QFR v4</li>
1500
  <li>SYNTAX score computation</li>
@@ -1546,7 +1568,7 @@ with gr.Blocks(css=CSS, title="Angio AI") as demo:
1546
 
1547
  with gr.Row():
1548
  with gr.Column():
1549
- gr.HTML('<div class="card-title" style="margin-bottom:6px">Coronary segmentation</div>')
1550
  seg_out = gr.Image(label="26-class overlay", height=300)
1551
  with gr.Column():
1552
  gr.HTML('<div class="card-title" style="margin-bottom:6px">FFR analysis</div>')
@@ -1608,5 +1630,5 @@ if __name__ == "__main__":
1608
  demo.launch(
1609
  server_name="0.0.0.0",
1610
  server_port=7860,
1611
- share=False,
1612
  )
 
24
  if "pyaudioop" not in sys.modules:
25
  sys.modules["pyaudioop"] = types.ModuleType("pyaudioop")
26
 
27
+ # ── Patch gradio_client _json_schema_to_python_type (APIInfoParseError fix) ──
28
+ def _patch_gradio_client():
29
+ try:
30
+ import gradio_client.utils as _gcu
31
+ _orig = _gcu._json_schema_to_python_type
32
+ def _safe(schema, defs=None):
33
+ if not isinstance(schema, dict):
34
+ return "Any"
35
+ try:
36
+ return _orig(schema, defs)
37
+ except Exception:
38
+ return "Any"
39
+ _gcu._json_schema_to_python_type = _safe
40
+ _orig_top = _gcu.json_schema_to_python_type
41
+ def _safe_top(schema, defs=None):
42
+ try:
43
+ return _orig_top(schema, defs)
44
+ except Exception:
45
+ return "Any"
46
+ _gcu.json_schema_to_python_type = _safe_top
47
+ except Exception:
48
+ pass
49
+ _patch_gradio_client()
50
+
51
  import os
52
  import sys
53
  import json
 
725
  f"Check HF_TOKEN secret and repo MuhammadAdil63/angio-ai-checkpoints"
726
  )
727
  print(f"[YOLO] Loading checkpoint: {ckpt}")
 
728
  try:
729
  import torch.serialization
730
  from ultralytics.nn.tasks import SegmentationModel
 
731
  torch.serialization.add_safe_globals([SegmentationModel])
732
  except Exception as _e:
733
  print(f"[YOLO] safe_globals warning: {_e}")
 
1516
  <ol style="font-size:13px;color:#1a2533;line-height:1.9;padding-left:16px">
1517
  <li>Best frame extracted from video</li>
1518
  <li>Stenosis detection β€” Mask2Former</li>
1519
+ <li>Coronary segmentation β€” 26-classes</li>
1520
  <li>Binary vessel mask β€” ResUNet</li>
1521
  <li>FFR estimation β€” QFR v4</li>
1522
  <li>SYNTAX score computation</li>
 
1568
 
1569
  with gr.Row():
1570
  with gr.Column():
1571
+ gr.HTML('<div class="card-title" style="margin-bottom:6px">Coronary segmentation </div>')
1572
  seg_out = gr.Image(label="26-class overlay", height=300)
1573
  with gr.Column():
1574
  gr.HTML('<div class="card-title" style="margin-bottom:6px">FFR analysis</div>')
 
1630
  demo.launch(
1631
  server_name="0.0.0.0",
1632
  server_port=7860,
1633
+ share=True,
1634
  )