Commit
·
5c7cdbe
1
Parent(s):
2c45fd9
Changed UI
Browse files- .DS_Store +0 -0
- app.py +49 -40
- src/.DS_Store +0 -0
.DS_Store
CHANGED
Binary files a/.DS_Store and b/.DS_Store differ
|
|
app.py
CHANGED
@@ -1,54 +1,63 @@
|
|
1 |
import gradio as gr
|
2 |
from src.pipeline import generate_report
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
try:
|
10 |
-
report = generate_report(
|
11 |
-
return
|
12 |
except Exception as e:
|
13 |
-
return
|
14 |
|
15 |
-
#
|
|
|
|
|
16 |
with gr.Blocks(title="Multi-Agent Radiology Assistant") as demo:
|
17 |
-
gr.Markdown(
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
output_image = gr.Image(
|
31 |
-
label="Analyzed Image",
|
32 |
-
height=400,
|
33 |
-
interactive=False
|
34 |
-
)
|
35 |
-
|
36 |
-
with gr.Row():
|
37 |
-
output_report = gr.Markdown(
|
38 |
-
label="📄 Radiology Report",
|
39 |
-
height=300
|
40 |
)
|
41 |
-
|
42 |
-
|
|
|
|
|
|
|
|
|
43 |
process_btn.click(
|
44 |
fn=process_upload,
|
45 |
-
inputs=
|
46 |
-
outputs=
|
47 |
)
|
48 |
-
|
49 |
-
# Add examples section
|
50 |
-
gr.Markdown("### Example X-rays")
|
51 |
-
gr.Markdown("*Upload your own chest X-ray image above to get started*")
|
52 |
|
|
|
|
|
|
|
53 |
if __name__ == "__main__":
|
54 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
from src.pipeline import generate_report
|
3 |
|
4 |
+
# ------------------------------------------------------------------
|
5 |
+
# 1. Pre-load models on Space start-up
|
6 |
+
# ------------------------------------------------------------------
|
7 |
+
print("Pre-loading models for fast inference …")
|
8 |
+
try:
|
9 |
+
from src.tools_loader import get_tools # downloads BiomedCLIP + SPECTER-2
|
10 |
+
_ = get_tools()
|
11 |
+
print("Models pre-loaded successfully!")
|
12 |
+
except Exception as e:
|
13 |
+
print(f"Model pre-loading failed: {e}")
|
14 |
+
|
15 |
+
# ------------------------------------------------------------------
|
16 |
+
# 2. Inference wrapper
|
17 |
+
# ------------------------------------------------------------------
|
18 |
+
def process_upload(image_path: str):
|
19 |
+
"""Run the multi-agent pipeline on an uploaded chest X-ray."""
|
20 |
+
if image_path is None:
|
21 |
+
return "Please upload a chest X-ray image."
|
22 |
+
|
23 |
try:
|
24 |
+
report = generate_report(image_path)
|
25 |
+
return report
|
26 |
except Exception as e:
|
27 |
+
return f"Error processing image: {e}"
|
28 |
|
29 |
+
# ------------------------------------------------------------------
|
30 |
+
# 3. Gradio UI
|
31 |
+
# ------------------------------------------------------------------
|
32 |
with gr.Blocks(title="Multi-Agent Radiology Assistant") as demo:
|
33 |
+
gr.Markdown(
|
34 |
+
"""
|
35 |
+
# Multi-Agent Radiology Assistant
|
36 |
+
Upload a chest X-ray and receive an AI-generated report produced by a multi-agent pipeline.
|
37 |
+
"""
|
38 |
+
)
|
39 |
+
|
40 |
+
# --- Upload widget + button ------------------------------------------------
|
41 |
+
with gr.Column():
|
42 |
+
input_image = gr.Image(
|
43 |
+
type="filepath",
|
44 |
+
label="Upload Chest X-ray",
|
45 |
+
height=400
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
)
|
47 |
+
process_btn = gr.Button("Generate Report", variant="primary")
|
48 |
+
|
49 |
+
# --- Report output ---------------------------------------------------------
|
50 |
+
output_report = gr.Markdown(label="Radiology Report", show_label=True)
|
51 |
+
|
52 |
+
# --- Wire everything together ---------------------------------------------
|
53 |
process_btn.click(
|
54 |
fn=process_upload,
|
55 |
+
inputs=input_image,
|
56 |
+
outputs=output_report
|
57 |
)
|
|
|
|
|
|
|
|
|
58 |
|
59 |
+
gr.Markdown("### Need an example? \nUse any frontal CXR PNG file and click **Generate Report**.")
|
60 |
+
|
61 |
+
# ------------------------------------------------------------------
|
62 |
if __name__ == "__main__":
|
63 |
demo.launch()
|
src/.DS_Store
CHANGED
Binary files a/src/.DS_Store and b/src/.DS_Store differ
|
|