File size: 1,734 Bytes
d8e0712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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()