Clocksp commited on
Commit
deb7667
·
verified ·
1 Parent(s): e36447c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -22
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
- iface = gr.Interface(
231
- fn=inference_pipeline,
232
- inputs=[
233
- gr.Image(type="numpy", label="Upload chest X-ray (RGB or grayscale)"),
234
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Bacterial threshold (thresh_b)"),
235
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Viral threshold (thresh_v)"),
236
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Segmentation mask threshold (seg_thresh)")
237
- ],
238
- outputs=[
239
- gr.Label(num_top_classes=1, label="Prediction"),
240
- gr.Number(label="Bacterial Probability"),
241
- gr.Number(label="Viral Probability"),
242
- gr.Image(type="pil", label="Masked Image (input × mask)"),
243
- gr.Image(type="pil", label="Segmentation Overlay (red mask)")
244
- ],
245
- title=title,
246
- description=desc
247
- )
248
- with gr.Blocks() as samples_block:
249
- gr.Markdown("### Test Samples")
 
 
 
 
 
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
- iface.launch()
 
 
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
+