Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -140,7 +140,7 @@ def analyze_report(file):
|
|
| 140 |
|
| 141 |
return report_summary
|
| 142 |
|
| 143 |
-
# Gradio Interface with enhanced UI
|
| 144 |
def create_interface():
|
| 145 |
with gr.Blocks() as demo:
|
| 146 |
custom_css = """
|
|
@@ -157,51 +157,55 @@ def create_interface():
|
|
| 157 |
gr.Markdown("<h1 class='title'>RadiologyScan AI</h1>")
|
| 158 |
gr.Markdown("<p style='text-align: center; color: #666;'>AI-powered analysis for X-rays and patient reports</p>")
|
| 159 |
|
| 160 |
-
with gr.
|
| 161 |
-
with gr.
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
| 174 |
-
|
| 175 |
-
|
| 176 |
-
|
| 177 |
-
|
| 178 |
-
|
| 179 |
-
|
| 180 |
-
|
| 181 |
-
|
| 182 |
-
|
| 183 |
-
|
| 184 |
-
|
| 185 |
-
|
| 186 |
-
|
| 187 |
-
|
| 188 |
-
|
| 189 |
-
|
| 190 |
-
|
| 191 |
-
|
| 192 |
-
|
| 193 |
-
|
| 194 |
-
|
| 195 |
-
|
| 196 |
-
|
| 197 |
-
|
| 198 |
-
|
| 199 |
-
|
| 200 |
-
|
| 201 |
-
|
| 202 |
-
|
| 203 |
-
|
| 204 |
-
|
| 205 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 206 |
demo = create_interface()
|
| 207 |
demo.launch(share=True)
|
|
|
|
| 140 |
|
| 141 |
return report_summary
|
| 142 |
|
| 143 |
+
# Gradio Interface with enhanced UI using Tabs
|
| 144 |
def create_interface():
|
| 145 |
with gr.Blocks() as demo:
|
| 146 |
custom_css = """
|
|
|
|
| 157 |
gr.Markdown("<h1 class='title'>RadiologyScan AI</h1>")
|
| 158 |
gr.Markdown("<p style='text-align: center; color: #666;'>AI-powered analysis for X-rays and patient reports</p>")
|
| 159 |
|
| 160 |
+
with gr.TabbedInterface() as tabs:
|
| 161 |
+
with gr.Tab("X-ray Analysis"):
|
| 162 |
+
with gr.Row():
|
| 163 |
+
xray_input = gr.Image(label="Upload X-ray", type="pil", elem_id="xray-input")
|
| 164 |
+
clear_xray_button = gr.Button("Clear X-ray", elem_classes="gradio-button")
|
| 165 |
+
with gr.Row():
|
| 166 |
+
predict_button = gr.Button("Analyze X-ray", elem_classes="gradio-button")
|
| 167 |
+
with gr.Column():
|
| 168 |
+
xray_output = gr.HTML(label="X-ray Diagnosis Summary", elem_classes="result-box")
|
| 169 |
+
xray_result = gr.HTML(label="Detailed X-ray Results", elem_classes="result-box")
|
| 170 |
+
additional_feedback = gr.HTML(label="Additional Feedback", elem_classes="result-box")
|
| 171 |
+
|
| 172 |
+
predict_button.click(
|
| 173 |
+
fn=predict_xray,
|
| 174 |
+
inputs=xray_input,
|
| 175 |
+
outputs=[xray_output, xray_result, additional_feedback]
|
| 176 |
+
)
|
| 177 |
+
|
| 178 |
+
# Clear X-ray button functionality
|
| 179 |
+
clear_xray_button.click(
|
| 180 |
+
fn=lambda: None, # Reset the x-ray image input
|
| 181 |
+
inputs=[],
|
| 182 |
+
outputs=[xray_input]
|
| 183 |
+
)
|
| 184 |
+
|
| 185 |
+
with gr.Tab("Report Analysis"):
|
| 186 |
+
with gr.Row():
|
| 187 |
+
report_input = gr.File(label="Upload Patient Report (PDF)", file_count="single", elem_id="report-input")
|
| 188 |
+
clear_report_button = gr.Button("Clear Report", elem_classes="gradio-button")
|
| 189 |
+
with gr.Row():
|
| 190 |
+
report_button = gr.Button("Analyze Report", elem_classes="gradio-button")
|
| 191 |
+
with gr.Column():
|
| 192 |
+
report_output = gr.Textbox(label="Report Summary", interactive=False, elem_classes="result-box")
|
| 193 |
+
|
| 194 |
+
report_button.click(
|
| 195 |
+
fn=analyze_report,
|
| 196 |
+
inputs=report_input,
|
| 197 |
+
outputs=report_output
|
| 198 |
+
)
|
| 199 |
+
|
| 200 |
+
# Clear Report button functionality
|
| 201 |
+
clear_report_button.click(
|
| 202 |
+
fn=lambda: None, # Reset the report file input
|
| 203 |
+
inputs=[],
|
| 204 |
+
outputs=[report_input]
|
| 205 |
+
)
|
| 206 |
+
|
| 207 |
+
return demo
|
| 208 |
+
|
| 209 |
+
# Launch the interface
|
| 210 |
demo = create_interface()
|
| 211 |
demo.launch(share=True)
|