ftx7go commited on
Commit
41658fe
·
verified ·
1 Parent(s): 0a42e87

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -59,7 +59,7 @@ def send_email(patient_email, report_path, patient_name):
59
  server.send_message(msg)
60
 
61
  # Function to process X-ray and generate a PDF report
62
- def generate_report(name, age, gender, weight, height, allergies, cause, xray, email):
63
  image_size = (224, 224)
64
 
65
  def predict_fracture(xray_path):
@@ -152,15 +152,8 @@ def generate_report(name, age, gender, weight, height, allergies, cause, xray, e
152
 
153
  c.save()
154
 
155
- # Send the report via email
156
- send_email(email, report_path, name)
157
-
158
  return report_path # Return path for auto-download
159
 
160
- # Function to select a sample image
161
- def use_sample_image(sample_image_path):
162
- return sample_image_path # Returns selected sample image filepath
163
-
164
  # Define Gradio Interface
165
  with gr.Blocks() as app:
166
  gr.HTML(html_content) # Display `re.html` content in Gradio
@@ -184,22 +177,23 @@ with gr.Blocks() as app:
184
 
185
  with gr.Row():
186
  xray = gr.Image(type="filepath", label="Upload X-ray Image")
187
-
188
- with gr.Row():
189
- sample_selector = gr.Dropdown(choices=sample_images, label="Use Sample Image")
190
- select_button = gr.Button("Load Sample Image")
191
 
192
  submit_button = gr.Button("Generate Report")
 
193
  output_file = gr.File(label="Download Report")
194
 
195
- select_button.click(use_sample_image, inputs=[sample_selector], outputs=[xray])
196
-
197
  submit_button.click(
198
  generate_report,
199
- inputs=[name, age, gender, weight, height, allergies, cause, xray, email],
200
  outputs=[output_file],
201
  )
202
 
 
 
 
 
 
 
203
  # Launch the Gradio app
204
  if __name__ == "__main__":
205
  app.launch()
 
59
  server.send_message(msg)
60
 
61
  # Function to process X-ray and generate a PDF report
62
+ def generate_report(name, age, gender, weight, height, allergies, cause, xray):
63
  image_size = (224, 224)
64
 
65
  def predict_fracture(xray_path):
 
152
 
153
  c.save()
154
 
 
 
 
155
  return report_path # Return path for auto-download
156
 
 
 
 
 
157
  # Define Gradio Interface
158
  with gr.Blocks() as app:
159
  gr.HTML(html_content) # Display `re.html` content in Gradio
 
177
 
178
  with gr.Row():
179
  xray = gr.Image(type="filepath", label="Upload X-ray Image")
 
 
 
 
180
 
181
  submit_button = gr.Button("Generate Report")
182
+ send_email_button = gr.Button("Send Report via Email")
183
  output_file = gr.File(label="Download Report")
184
 
 
 
185
  submit_button.click(
186
  generate_report,
187
+ inputs=[name, age, gender, weight, height, allergies, cause, xray],
188
  outputs=[output_file],
189
  )
190
 
191
+ send_email_button.click(
192
+ send_email,
193
+ inputs=[email, output_file, name],
194
+ outputs=[],
195
+ )
196
+
197
  # Launch the Gradio app
198
  if __name__ == "__main__":
199
  app.launch()