Upload 4 files
Browse files- app.py +15 -6
- patch.diff +17 -0
app.py
CHANGED
|
@@ -1,4 +1,4 @@
|
|
| 1 |
-
import json
|
| 2 |
import os
|
| 3 |
from functools import lru_cache
|
| 4 |
from pathlib import Path
|
|
@@ -33,7 +33,7 @@ processor = AutoProcessor.from_pretrained(
|
|
| 33 |
model = AutoModelForZeroShotImageClassification.from_pretrained(
|
| 34 |
MODEL_ID,
|
| 35 |
token=HF_TOKEN,
|
| 36 |
-
|
| 37 |
).to(device)
|
| 38 |
model.eval()
|
| 39 |
|
|
@@ -84,12 +84,21 @@ def classify_medical_image(image_path: str) -> Dict[str, float]:
|
|
| 84 |
|
| 85 |
demo = gr.Interface(
|
| 86 |
fn=classify_medical_image,
|
| 87 |
-
inputs=gr.Image(type="filepath", label="
|
| 88 |
-
outputs=gr.Label(num_top_classes=5, label="
|
| 89 |
-
title="
|
| 90 |
description="Zero-shot model with automatic label filtering for different modalities.",
|
| 91 |
)
|
| 92 |
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import json
|
| 2 |
import os
|
| 3 |
from functools import lru_cache
|
| 4 |
from pathlib import Path
|
|
|
|
| 33 |
model = AutoModelForZeroShotImageClassification.from_pretrained(
|
| 34 |
MODEL_ID,
|
| 35 |
token=HF_TOKEN,
|
| 36 |
+
dtype=torch.float32,
|
| 37 |
).to(device)
|
| 38 |
model.eval()
|
| 39 |
|
|
|
|
| 84 |
|
| 85 |
demo = gr.Interface(
|
| 86 |
fn=classify_medical_image,
|
| 87 |
+
inputs=gr.Image(type="filepath", label="Upload Medical Image"),
|
| 88 |
+
outputs=gr.Label(num_top_classes=5, label="Top Predictions"),
|
| 89 |
+
title="MedSigLIP Smart Medical Classifier",
|
| 90 |
description="Zero-shot model with automatic label filtering for different modalities.",
|
| 91 |
)
|
| 92 |
|
| 93 |
|
| 94 |
if __name__ == "__main__":
|
| 95 |
+
server_name = os.getenv("SERVER_NAME", "0.0.0.0")
|
| 96 |
+
port_env = os.getenv("SERVER_PORT") or os.getenv("PORT") or "7860"
|
| 97 |
+
share_env = os.getenv("GRADIO_SHARE", "false").lower()
|
| 98 |
+
|
| 99 |
+
demo.queue().launch(
|
| 100 |
+
server_name=server_name,
|
| 101 |
+
server_port=int(port_env),
|
| 102 |
+
share=share_env in {"1", "true", "yes"},
|
| 103 |
+
show_api=False,
|
| 104 |
+
)
|
patch.diff
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
*** Begin Patch
|
| 2 |
+
*** Update File: medsiglip-smart-filter/app.py
|
| 3 |
+
@@
|
| 4 |
+
-if __name__ == "__main__":
|
| 5 |
+
- server_name = os.getenv("SERVER_NAME", "0.0.0.0")\\nport_env = os.getenv("SERVER_PORT") or os.getenv("PORT") or "7860"\\nshare_env = os.getenv("GRADIO_SHARE", "false").lower()\\n\\ndemo.queue().launch(\\n server_name=server_name,\\n server_port=int(port_env),\\n share=share_env in {"1", "true", "yes"},\\n show_api=False,\\n)
|
| 6 |
+
+if __name__ == "__main__":
|
| 7 |
+
+ server_name = os.getenv("SERVER_NAME", "0.0.0.0")
|
| 8 |
+
+ port_env = os.getenv("SERVER_PORT") or os.getenv("PORT") or "7860"
|
| 9 |
+
+ share_env = os.getenv("GRADIO_SHARE", "false").lower()
|
| 10 |
+
+
|
| 11 |
+
+ demo.queue().launch(
|
| 12 |
+
+ server_name=server_name,
|
| 13 |
+
+ server_port=int(port_env),
|
| 14 |
+
+ share=share_env in {"1", "true", "yes"},
|
| 15 |
+
+ show_api=False,
|
| 16 |
+
+ )
|
| 17 |
+
*** End Patch
|