Update app.py
Browse files
app.py
CHANGED
|
@@ -227,26 +227,31 @@ title = "Chest X-ray: UNet segmentation + 2 binary classifiers"
|
|
| 227 |
desc = "Pipeline: UNet -> mask lungs -> two binary classifiers (Normal vs Bacterial, Normal vs Viral). " \
|
| 228 |
"If both classifiers fire, the stronger probability is chosen (fallback). Thresholds adjustable."
|
| 229 |
|
| 230 |
-
|
| 231 |
-
|
| 232 |
-
|
| 233 |
-
|
| 234 |
-
|
| 235 |
-
gr.
|
| 236 |
-
|
| 237 |
-
|
| 238 |
-
|
| 239 |
-
|
| 240 |
-
|
| 241 |
-
gr.
|
| 242 |
-
|
| 243 |
-
|
| 244 |
-
|
| 245 |
-
|
| 246 |
-
|
| 247 |
-
|
| 248 |
-
|
| 249 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 250 |
|
| 251 |
with gr.Row():
|
| 252 |
with gr.Column():
|
|
@@ -266,6 +271,6 @@ with gr.Blocks() as samples_block:
|
|
| 266 |
with gr.Column():
|
| 267 |
gr.Markdown("**BACTERIAL**")
|
| 268 |
|
| 269 |
-
|
| 270 |
if __name__ == "__main__":
|
| 271 |
-
|
|
|
|
|
|
| 227 |
desc = "Pipeline: UNet -> mask lungs -> two binary classifiers (Normal vs Bacterial, Normal vs Viral). " \
|
| 228 |
"If both classifiers fire, the stronger probability is chosen (fallback). Thresholds adjustable."
|
| 229 |
|
| 230 |
+
with gr.Blocks(title=title) as demo:
|
| 231 |
+
|
| 232 |
+
gr.Markdown(f"## {title}\n{desc}")
|
| 233 |
+
|
| 234 |
+
with gr.Row():
|
| 235 |
+
with gr.Column():
|
| 236 |
+
img_in = gr.Image(type="numpy", label="Upload chest X-ray")
|
| 237 |
+
thresh_b = gr.Slider(0.1, 0.9, 0.5, step=0.01, label="Bacterial threshold")
|
| 238 |
+
thresh_v = gr.Slider(0.1, 0.9, 0.5, step=0.01, label="Viral threshold")
|
| 239 |
+
seg_thresh = gr.Slider(0.1, 0.9, 0.5, step=0.01, label="Segmentation mask threshold")
|
| 240 |
+
|
| 241 |
+
with gr.Column():
|
| 242 |
+
pred_out = gr.Label(num_top_classes=1, label="Prediction")
|
| 243 |
+
pb_out = gr.Number(label="Bacterial Probability")
|
| 244 |
+
pv_out = gr.Number(label="Viral Probability")
|
| 245 |
+
masked_img_out = gr.Image(type="pil", label="Masked Image")
|
| 246 |
+
overlay_out = gr.Image(type="pil", label="Segmentation Overlay")
|
| 247 |
+
|
| 248 |
+
img_in.change(
|
| 249 |
+
inference_pipeline,
|
| 250 |
+
inputs=[img_in, thresh_b, thresh_v, seg_thresh],
|
| 251 |
+
outputs=[pred_out, pb_out, pv_out, masked_img_out, overlay_out]
|
| 252 |
+
)
|
| 253 |
+
|
| 254 |
+
gr.Markdown("## Test Samples")
|
| 255 |
|
| 256 |
with gr.Row():
|
| 257 |
with gr.Column():
|
|
|
|
| 271 |
with gr.Column():
|
| 272 |
gr.Markdown("**BACTERIAL**")
|
| 273 |
|
|
|
|
| 274 |
if __name__ == "__main__":
|
| 275 |
+
demo.launch()
|
| 276 |
+
|