ariankhalfani commited on
Commit
36b6162
1 Parent(s): 714cfbf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +2 -5
app.py CHANGED
@@ -203,24 +203,21 @@ def view_database():
203
 
204
  # Function to download database or image
205
  def download_file(choice):
206
- # Ensure the directory exists
207
  directory = "/mnt/data"
208
  if not os.path.exists(directory):
209
  os.makedirs(directory)
210
 
211
  if choice == "Database (.db)":
212
- # Provide the path to the database file
213
  return 'results.db'
214
  elif choice == "Database (.html)":
215
  conn = sqlite3.connect('results.db')
216
  df = pd.read_sql_query("SELECT * FROM results", conn)
217
  conn.close()
218
 
219
- # Save the DataFrame as an HTML file
220
  html_file_path = os.path.join(directory, "results.html")
221
  df.to_html(html_file_path, index=False)
222
 
223
- return html_file_path
224
 
225
  # Initialize the database
226
  init_db()
@@ -228,7 +225,7 @@ init_db()
228
  # Gradio Interface
229
  def interface(name, age, medical_record, sex, input_image):
230
  if input_image is None:
231
- return "Please upload an image."
232
 
233
  output_image, raw_result = predict_image(input_image, name, age, medical_record, sex)
234
  submit_status = submit_result(name, age, medical_record, sex, input_image, output_image, raw_result)
 
203
 
204
  # Function to download database or image
205
  def download_file(choice):
 
206
  directory = "/mnt/data"
207
  if not os.path.exists(directory):
208
  os.makedirs(directory)
209
 
210
  if choice == "Database (.db)":
 
211
  return 'results.db'
212
  elif choice == "Database (.html)":
213
  conn = sqlite3.connect('results.db')
214
  df = pd.read_sql_query("SELECT * FROM results", conn)
215
  conn.close()
216
 
 
217
  html_file_path = os.path.join(directory, "results.html")
218
  df.to_html(html_file_path, index=False)
219
 
220
+ return html_file_path # Ensure the path is returned as a string
221
 
222
  # Initialize the database
223
  init_db()
 
225
  # Gradio Interface
226
  def interface(name, age, medical_record, sex, input_image):
227
  if input_image is None:
228
+ return None, "Please upload an image.", None
229
 
230
  output_image, raw_result = predict_image(input_image, name, age, medical_record, sex)
231
  submit_status = submit_result(name, age, medical_record, sex, input_image, output_image, raw_result)