fokan commited on
Commit
6281b8a
·
verified ·
1 Parent(s): 8081710

Upload 3 files

Browse files
Files changed (2) hide show
  1. README.md +2 -2
  2. app.py +11 -1
README.md CHANGED
@@ -25,7 +25,7 @@ Zero-shot image classification for medical imagery powered by **google/medsiglip
25
  - Smart Modality Router v2 blends filename heuristics, simple color statistics, and a lightweight fallback classifier to choose the best label bank.
26
  - CT, Ultrasound, Musculoskeletal, chest X-ray, brain MRI, fundus, histopathology, skin, cardiovascular, and general label libraries curated from MedSigLIP prompts and clinical references.
27
  - CPU-optimized inference with single model load, float32 execution on CPU, capped torch threads, cached results, and batched label scoring.
28
- - Gradio interface ready for local execution or deployment to Hugging Face Spaces (verified on Gradio 4.44.1+).
29
 
30
 
31
  ## Project Structure
@@ -115,7 +115,7 @@ Each label file contains 100-200 modality-specific diagnostic phrases reflecting
115
  1. Create a new Space (Gradio template) named `medsiglip-smart-filter`.
116
  2. Push the project files to the Space repository (via `git` or the web UI).
117
  3. In **Settings -> Repository Secrets**, add `HF_TOKEN` with your Hugging Face access token so the model and auxiliary router weights can be downloaded during build.
118
- 4. The default `python app.py` launch serves the Gradio interface at `https://<space-name>.hf.space`.
119
 
120
 
121
  ## Model Reference Update
 
25
  - Smart Modality Router v2 blends filename heuristics, simple color statistics, and a lightweight fallback classifier to choose the best label bank.
26
  - CT, Ultrasound, Musculoskeletal, chest X-ray, brain MRI, fundus, histopathology, skin, cardiovascular, and general label libraries curated from MedSigLIP prompts and clinical references.
27
  - CPU-optimized inference with single model load, float32 execution on CPU, capped torch threads, cached results, and batched label scoring.
28
+ - Gradio interface ready for local execution or deployment to Hugging Face Spaces (verified on Gradio 4.44.1+, API disabled by default to avoid schema bugs).
29
 
30
 
31
  ## Project Structure
 
115
  1. Create a new Space (Gradio template) named `medsiglip-smart-filter`.
116
  2. Push the project files to the Space repository (via `git` or the web UI).
117
  3. In **Settings -> Repository Secrets**, add `HF_TOKEN` with your Hugging Face access token so the model and auxiliary router weights can be downloaded during build.
118
+ 4. The default `python app.py` launch honors `SERVER_PORT`, `SERVER_NAME`, and `GRADIO_SHARE` if set by the Space runner.
119
 
120
 
121
  ## Model Reference Update
app.py CHANGED
@@ -81,8 +81,18 @@ demo = gr.Interface(
81
  outputs=gr.Label(num_top_classes=5, label="🧠 Top Predictions"),
82
  title="🩻 MedSigLIP Smart Medical Classifier",
83
  description="Zero-shot model with automatic label filtering for different modalities.",
 
84
  )
85
 
86
 
87
  if __name__ == "__main__":
88
- demo.launch()
 
 
 
 
 
 
 
 
 
 
81
  outputs=gr.Label(num_top_classes=5, label="🧠 Top Predictions"),
82
  title="🩻 MedSigLIP Smart Medical Classifier",
83
  description="Zero-shot model with automatic label filtering for different modalities.",
84
+ allow_api=False,
85
  )
86
 
87
 
88
  if __name__ == "__main__":
89
+ server_name = os.getenv("SERVER_NAME", "0.0.0.0")
90
+ port_env = os.getenv("SERVER_PORT") or os.getenv("PORT") or "7860"
91
+ share_env = os.getenv("GRADIO_SHARE", "false").lower()
92
+
93
+ demo.launch(
94
+ server_name=server_name,
95
+ server_port=int(port_env),
96
+ share=share_env in {"1", "true", "yes"},
97
+ show_api=False,
98
+ )