|
import gradio as gr |
|
from src.pipeline import generate_report |
|
|
|
def process_upload(image): |
|
"""Process uploaded X-ray image and return radiology report""" |
|
if image is None: |
|
return None, "Please upload a chest X-ray image." |
|
|
|
try: |
|
report = generate_report(image) |
|
return image, report |
|
except Exception as e: |
|
return image, f"Error processing image: {str(e)}" |
|
|
|
|
|
with gr.Blocks(title="Multi-Agent Radiology Assistant") as demo: |
|
gr.Markdown("# Multi-Agent Radiology Assistant") |
|
gr.Markdown("Upload a chest X-ray image to receive an AI-generated radiology report using cutting-edge, multi-agent analysis") |
|
|
|
with gr.Row(): |
|
with gr.Column(scale=1): |
|
input_image = gr.Image( |
|
type="filepath", |
|
label="Upload Chest X-ray", |
|
height=400 |
|
) |
|
process_btn = gr.Button("Generate Report", variant="primary") |
|
|
|
with gr.Column(scale=1): |
|
output_image = gr.Image( |
|
label="Analyzed Image", |
|
height=400, |
|
interactive=False |
|
) |
|
|
|
with gr.Row(): |
|
output_report = gr.Markdown( |
|
label="π Radiology Report", |
|
height=300 |
|
) |
|
|
|
|
|
process_btn.click( |
|
fn=process_upload, |
|
inputs=[input_image], |
|
outputs=[output_image, output_report] |
|
) |
|
|
|
|
|
gr.Markdown("### Example X-rays") |
|
gr.Markdown("*Upload your own chest X-ray image above to get started*") |
|
|
|
if __name__ == "__main__": |
|
demo.launch() |