samyakshrestha's picture
Deploy multi-agent radiology assistant
d8e0712
raw
history blame
1.73 kB
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 # Return both image and report
except Exception as e:
return image, f"Error processing image: {str(e)}"
# Create enhanced Gradio interface with custom layout
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
)
# Connect the button to processing function
process_btn.click(
fn=process_upload,
inputs=[input_image],
outputs=[output_image, output_report]
)
# Add examples section
gr.Markdown("### Example X-rays")
gr.Markdown("*Upload your own chest X-ray image above to get started*")
if __name__ == "__main__":
demo.launch()