VaneshDev commited on
Commit
293252f
·
verified ·
1 Parent(s): 1a5c21d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +51 -47
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.Row():
161
- with gr.Column(scale=1):
162
- xray_input = gr.Image(label="Upload X-ray", type="pil", elem_id="xray-input")
163
- clear_xray_button = gr.Button("Clear X-ray", elem_classes="gradio-button")
164
- with gr.Column(scale=1):
165
- report_input = gr.File(label="Upload Patient Report (PDF)", file_count="single", elem_id="report-input")
166
-
167
- with gr.Row():
168
- # Grouping the Analyze and Clear buttons in the same row for Report
169
- report_button = gr.Button("Analyze Report", elem_classes="gradio-button")
170
- clear_report_button = gr.Button("Clear Report", elem_classes="gradio-button")
171
-
172
- with gr.Row():
173
- predict_button = gr.Button("Analyze X-ray", elem_classes="gradio-button")
174
-
175
- with gr.Column():
176
- xray_output = gr.HTML(label="X-ray Diagnosis Summary", elem_classes="result-box")
177
- xray_result = gr.HTML(label="Detailed X-ray Results", elem_classes="result-box")
178
- additional_feedback = gr.HTML(label="Additional Feedback", elem_classes="result-box")
179
- report_output = gr.Textbox(label="Report Summary", interactive=False, elem_classes="result-box")
180
-
181
- predict_button.click(
182
- fn=predict_xray,
183
- inputs=xray_input,
184
- outputs=[xray_output, xray_result, additional_feedback]
185
- )
186
- report_button.click(
187
- fn=analyze_report,
188
- inputs=report_input,
189
- outputs=report_output)
190
-
191
- # Clear buttons functionality
192
- clear_xray_button.click(
193
- fn=lambda: None, # Reset the x-ray image input
194
- inputs=[],
195
- outputs=[xray_input]
196
- )
197
- clear_report_button.click(
198
- fn=lambda: None, # Reset the report file input
199
- inputs=[],
200
- outputs=[report_input]
201
- )
202
-
203
- return demo
204
-
205
- # Launch the interface and save model after training (to be implemented by user)
 
 
 
 
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)