Spaces:
Sleeping
Sleeping
Pavan Praneeth commited on
Commit ·
8bc4c8f
1
Parent(s): 9667248
Fix Gradio image schema and SDK versions
Browse files
README.md
CHANGED
|
@@ -4,7 +4,7 @@ emoji: 🔬
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
-
sdk_version: "4.
|
| 8 |
python_version: "3.10"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
|
|
|
| 4 |
colorFrom: indigo
|
| 5 |
colorTo: purple
|
| 6 |
sdk: gradio
|
| 7 |
+
sdk_version: "4.42.0"
|
| 8 |
python_version: "3.10"
|
| 9 |
app_file: app.py
|
| 10 |
pinned: false
|
app.py
CHANGED
|
@@ -84,12 +84,12 @@ def make_overlay(original_rgb: np.ndarray, mask: np.ndarray) -> np.ndarray:
|
|
| 84 |
# Inference function (called by Gradio)
|
| 85 |
# ---------------------------------------------------------------------------
|
| 86 |
|
| 87 |
-
def segment(
|
| 88 |
"""Run inference and return (mask_image, overlay_image)."""
|
| 89 |
-
if
|
| 90 |
return None, None
|
| 91 |
|
| 92 |
-
pil_img =
|
| 93 |
tensor = preprocess(pil_img)
|
| 94 |
with torch.no_grad():
|
| 95 |
pred = MODEL(tensor) # (1, 1, 256, 256)
|
|
@@ -128,7 +128,7 @@ with gr.Blocks(theme=gr.themes.Soft(), title="ISIC Skin Lesion Segmentation") as
|
|
| 128 |
|
| 129 |
with gr.Row():
|
| 130 |
with gr.Column():
|
| 131 |
-
inp = gr.Image(label="Input Image", type="
|
| 132 |
btn = gr.Button("Segment 🔍", variant="primary")
|
| 133 |
with gr.Column():
|
| 134 |
out_mask = gr.Image(label="Predicted Mask")
|
|
|
|
| 84 |
# Inference function (called by Gradio)
|
| 85 |
# ---------------------------------------------------------------------------
|
| 86 |
|
| 87 |
+
def segment(pil_img):
|
| 88 |
"""Run inference and return (mask_image, overlay_image)."""
|
| 89 |
+
if pil_img is None:
|
| 90 |
return None, None
|
| 91 |
|
| 92 |
+
pil_img = pil_img.convert("RGB")
|
| 93 |
tensor = preprocess(pil_img)
|
| 94 |
with torch.no_grad():
|
| 95 |
pred = MODEL(tensor) # (1, 1, 256, 256)
|
|
|
|
| 128 |
|
| 129 |
with gr.Row():
|
| 130 |
with gr.Column():
|
| 131 |
+
inp = gr.Image(label="Input Image", type="pil")
|
| 132 |
btn = gr.Button("Segment 🔍", variant="primary")
|
| 133 |
with gr.Column():
|
| 134 |
out_mask = gr.Image(label="Predicted Mask")
|