Clocksp commited on
Commit
328c913
·
verified ·
1 Parent(s): b59b511

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +45 -5
app.py CHANGED
@@ -227,6 +227,50 @@ 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=[
@@ -242,11 +286,7 @@ iface = gr.Interface(
242
  gr.Image(type="pil", label="Masked Image (input × mask)"),
243
  gr.Image(type="pil", label="Segmentation Overlay (red mask)")
244
  ],
245
- gr.examples=[
246
- ["images/NORMAL.jpg", 0.5, 0.5, 0.5,label="NORMAL"],
247
- ["images/VIRAL.jpg", 0.5, 0.5, 0.5,label="VIRAL"],
248
- ["images/BACT.jpg", 0.5, 0.5, 0.5,label="BACTERIAL"],
249
- ],
250
  title=title,
251
  description=desc,
252
  allow_flagging="never"
 
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() as demo:
231
+
232
+ gr.Markdown("### Example Table (Image + True Label)")
233
+
234
+ example_samples = [
235
+ ["images/NORMAL.jpg", "NORMAL"],
236
+ ["images/VIRAL.jpg", "VIRAL"],
237
+ ["images/BACT.jpg", "BACTERIAL"],
238
+ ]
239
+
240
+ gr.Dataset(
241
+ samples=example_samples,
242
+ components=[
243
+ gr.Image(type="filepath", label="Image"),
244
+ gr.Textbox(label="True Label")
245
+ ],
246
+ headers=["Image", "Label"],
247
+ label="Examples",
248
+ layout="table"
249
+ )
250
+
251
+ iface = gr.Interface(
252
+ fn=inference_pipeline,
253
+ inputs=[
254
+ gr.Image(type="numpy", label="Upload chest X-ray (RGB or grayscale)"),
255
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Bacterial threshold (thresh_b)"),
256
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Viral threshold (thresh_v)"),
257
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Segmentation mask threshold (seg_thresh)")
258
+ ],
259
+ outputs=[
260
+ gr.Label(num_top_classes=1, label="Prediction"),
261
+ gr.Number(label="Bacterial Probability"),
262
+ gr.Number(label="Viral Probability"),
263
+ gr.Image(type="pil", label="Masked Image (input × mask)"),
264
+ gr.Image(type="pil", label="Segmentation Overlay (red mask)")
265
+ ],
266
+ title=title,
267
+ description=desc,
268
+ allow_flagging="never"
269
+ )
270
+
271
+ demo.launch(share=False)
272
+
273
+
274
  iface = gr.Interface(
275
  fn=inference_pipeline,
276
  inputs=[
 
286
  gr.Image(type="pil", label="Masked Image (input × mask)"),
287
  gr.Image(type="pil", label="Segmentation Overlay (red mask)")
288
  ],
289
+
 
 
 
 
290
  title=title,
291
  description=desc,
292
  allow_flagging="never"