Clocksp commited on
Commit
ed5eb7a
·
verified ·
1 Parent(s): 88407d5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +42 -39
app.py CHANGED
@@ -228,44 +228,47 @@ desc = "Pipeline: UNet -> mask lungs -> two binary classifiers (Normal vs Bacter
228
  "If both classifiers fire, the stronger probability is chosen (fallback). Thresholds adjustable."
229
 
230
 
231
- iface = gr.Interface(
232
- fn=inference_pipeline,
233
- inputs=[
234
- gr.Image(type="numpy", label="Upload chest X-ray (RGB or grayscale)"),
235
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Bacterial threshold (thresh_b)"),
236
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Viral threshold (thresh_v)"),
237
- gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Segmentation mask threshold (seg_thresh)")
238
- ],
239
- outputs=[
240
- gr.Label(num_top_classes=1, label="Prediction"),
241
- gr.Number(label="Bacterial Probability"),
242
- gr.Number(label="Viral Probability"),
243
- gr.Image(type="pil", label="Masked Image (input × mask)"),
244
- gr.Image(type="pil", label="Segmentation Overlay (red mask)")
245
- ],
246
-
247
- title=title,
248
- description=desc,
249
- allow_flagging="never"
250
- )
251
- gr.Markdown("### Example Images with True Labels")
252
-
253
- example_samples = [
254
- ["images/NORMAL.jpeg", "NORMAL"],
255
- ["images/VIRAL.jpeg", "VIRAL"],
256
- ["images/BACT.jpeg", "BACTERIAL"],
257
- ]
258
-
259
- gr.Dataset(
260
- samples=example_samples,
261
- components=[
262
- gr.Image(type="filepath", label="Image"),
263
- gr.Textbox(label="True Label")
264
- ],
265
- headers=["Image", "Label"],
266
- label="Test Samples",
267
- layout="table"
268
- )
 
 
 
269
 
270
  if __name__ == "__main__":
271
- iface.launch(share=False)
 
228
  "If both classifiers fire, the stronger probability is chosen (fallback). Thresholds adjustable."
229
 
230
 
231
+ with gr.Blocks() as demo:
232
+
233
+ iface = gr.Interface(
234
+ fn=inference_pipeline,
235
+ inputs=[
236
+ gr.Image(type="numpy", label="Upload chest X-ray (RGB or grayscale)"),
237
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Bacterial threshold (thresh_b)"),
238
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Viral threshold (thresh_v)"),
239
+ gr.Slider(minimum=0.1, maximum=0.9, step=0.01, value=0.5, label="Segmentation mask threshold (seg_thresh)")
240
+ ],
241
+ outputs=[
242
+ gr.Label(num_top_classes=1, label="Prediction"),
243
+ gr.Number(label="Bacterial Probability"),
244
+ gr.Number(label="Viral Probability"),
245
+ gr.Image(type="pil", label="Masked Image (input × mask)"),
246
+ gr.Image(type="pil", label="Segmentation Overlay (red mask)")
247
+ ],
248
+ title=title,
249
+ description=desc,
250
+ allow_flagging="never"
251
+ )
252
+
253
+
254
+ gr.Markdown("### Example Images with True Labels")
255
+
256
+ example_samples = [
257
+ ["images/NORMAL.jpg", "NORMAL"],
258
+ ["images/VIRAL.jpg", "VIRAL"],
259
+ ["images/BACT.jpg", "BACTERIAL"],
260
+ ]
261
+
262
+ gr.Dataset(
263
+ samples=example_samples,
264
+ components=[
265
+ gr.Image(type="filepath", label="Image"),
266
+ gr.Textbox(label="True Label")
267
+ ],
268
+ headers=["Image", "Label"],
269
+ label="Test Samples",
270
+ layout="table"
271
+ )
272
 
273
  if __name__ == "__main__":
274
+ demo.launch(share=False)