junma commited on
Commit
f974aa8
路
verified 路
1 Parent(s): 7cdddbb

Move demo to module scope so Gradio autoloader can find it (fixes hot-reload double-launch)

Browse files
Files changed (1) hide show
  1. app.py +6 -7
app.py CHANGED
@@ -319,7 +319,7 @@ def build_interface(model, pad_func, examples_dir):
319
  "Weights 漏 2026 DAMO Academy 路 Paper: "
320
  "[Science 2026, eaec6129](https://www.science.org/doi/10.1126/science.aec6129) 路 "
321
  "Code: [alibaba-damo-academy/damo-radar](https://github.com/alibaba-damo-academy/damo-radar). \n"
322
- "More cases for testing: [PancancerCTSeg](https://huggingface.co/datasets/FLARE-MedFM/PancancerCTSeg).\n\n"
323
  "Demo built by [Jun Ma](https://scholar.google.com/citations?hl=en&user=bW1UV4IAAAAJ)."
324
  )
325
  with gr.Row():
@@ -361,11 +361,10 @@ def build_interface(model, pad_func, examples_dir):
361
  return demo
362
 
363
 
364
- def main():
365
- pad_func, model = initialize_cpu()
366
- demo = build_interface(model, pad_func, str(THIS_DIR / "example"))
367
- demo.queue().launch()
368
-
369
 
370
  if __name__ == "__main__":
371
- main()
 
319
  "Weights 漏 2026 DAMO Academy 路 Paper: "
320
  "[Science 2026, eaec6129](https://www.science.org/doi/10.1126/science.aec6129) 路 "
321
  "Code: [alibaba-damo-academy/damo-radar](https://github.com/alibaba-damo-academy/damo-radar). \n"
322
+ "More public cases for testing: [PancancerCTSeg](https://huggingface.co/datasets/FLARE-MedFM/PancancerCTSeg).\n\n"
323
  "Demo built by [Jun Ma](https://scholar.google.com/citations?hl=en&user=bW1UV4IAAAAJ)."
324
  )
325
  with gr.Row():
 
361
  return demo
362
 
363
 
364
+ # Build `demo` at module level so HF Spaces / Gradio hot-reload can discover it.
365
+ pad_func, model = initialize_cpu()
366
+ demo = build_interface(model, pad_func, str(THIS_DIR / "example"))
367
+ demo.queue()
 
368
 
369
  if __name__ == "__main__":
370
+ demo.launch()