Benny-Tang commited on
Commit
f887276
·
verified ·
1 Parent(s): 7ded304

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -1,4 +1,3 @@
1
- import json
2
  import numpy as np
3
  import gradio as gr
4
  from PIL import Image
@@ -9,6 +8,7 @@ from skimage.transform import resize as sk_resize
9
  import matplotlib.pyplot as plt
10
  import io
11
  import re
 
12
 
13
  # -----------------------------
14
  # Imaging Agent (Chest X-ray)
@@ -66,11 +66,11 @@ def imaging_agent(image_path: str):
66
 
67
  # Format outputs
68
  lines = [f"{name}: {p*100:.1f}%" for name, p in sorted(focus, key=lambda x: x[1], reverse=True)]
69
- table = {name: round(p, 4) for name, p in focus}
70
 
71
  return (
72
  "🖼️ Imaging Agent (Chest X-ray for cancer risk)\n" + "\n".join(lines),
73
- json.dumps(table, indent=2),
74
  heatmap_img
75
  )
76
 
@@ -142,10 +142,10 @@ SAMPLE_TEXTS = {
142
  # Runner
143
  # -----------------------------
144
  def run_all(image, labs):
145
- txt, raw, heatmap = imaging_agent(image) if image else ("No image.", None, None)
146
  lab = lab_agent(labs)
147
  coord = coordinator(txt, lab)
148
- return txt, raw, heatmap, lab, coord
149
 
150
 
151
  # -----------------------------
@@ -164,7 +164,7 @@ with gr.Blocks(theme="soft") as demo:
164
  )
165
  img_in = gr.Image(type="filepath", label="Chest X-ray (PNG/JPG)")
166
  imaging_out = gr.Textbox(label="Imaging Agent Output")
167
- imaging_raw = gr.Code(label="Probabilities JSON", language="json")
168
  imaging_heatmap = gr.Image(label="Heatmap Overlay")
169
  with gr.Column():
170
  text_dropdown = gr.Dropdown(
@@ -209,3 +209,4 @@ demo.launch()
209
 
210
 
211
 
 
 
 
1
  import numpy as np
2
  import gradio as gr
3
  from PIL import Image
 
8
  import matplotlib.pyplot as plt
9
  import io
10
  import re
11
+ import json
12
 
13
  # -----------------------------
14
  # Imaging Agent (Chest X-ray)
 
66
 
67
  # Format outputs
68
  lines = [f"{name}: {p*100:.1f}%" for name, p in sorted(focus, key=lambda x: x[1], reverse=True)]
69
+ prob_text = "\n".join(lines)
70
 
71
  return (
72
  "🖼️ Imaging Agent (Chest X-ray for cancer risk)\n" + "\n".join(lines),
73
+ prob_text,
74
  heatmap_img
75
  )
76
 
 
142
  # Runner
143
  # -----------------------------
144
  def run_all(image, labs):
145
+ txt, prob_text, heatmap = imaging_agent(image) if image else ("No image.", None, None)
146
  lab = lab_agent(labs)
147
  coord = coordinator(txt, lab)
148
+ return txt, prob_text, heatmap, lab, coord
149
 
150
 
151
  # -----------------------------
 
164
  )
165
  img_in = gr.Image(type="filepath", label="Chest X-ray (PNG/JPG)")
166
  imaging_out = gr.Textbox(label="Imaging Agent Output")
167
+ imaging_raw = gr.Textbox(label="Probabilities (%)", lines=6)
168
  imaging_heatmap = gr.Image(label="Heatmap Overlay")
169
  with gr.Column():
170
  text_dropdown = gr.Dropdown(
 
209
 
210
 
211
 
212
+