Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
32d2049
1
Parent(s):
5d3655e
Update app.py
Browse files
app.py
CHANGED
@@ -205,20 +205,16 @@ def download_file(choice):
|
|
205 |
if choice == "Database (.db)":
|
206 |
# Provide the path to the database file
|
207 |
return 'results.db'
|
208 |
-
|
209 |
conn = sqlite3.connect('results.db')
|
210 |
-
|
211 |
-
c.execute("SELECT predicted_image FROM results ORDER BY id DESC LIMIT 1")
|
212 |
-
row = c.fetchone()
|
213 |
conn.close()
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
else:
|
221 |
-
raise FileNotFoundError("No images found in the database.")
|
222 |
|
223 |
# Initialize the database
|
224 |
init_db()
|
@@ -252,7 +248,6 @@ with gr.Blocks() as demo:
|
|
252 |
with gr.Column():
|
253 |
gr.Markdown("# Cataract Detection System")
|
254 |
gr.Markdown("Upload an image to detect cataract and add patient details.")
|
255 |
-
gr.Image("PR_curve.png", label="Model PR Curve")
|
256 |
gr.Markdown("This application uses YOLOv8 with mAP=0.981")
|
257 |
|
258 |
with gr.Column():
|
@@ -279,7 +274,7 @@ with gr.Blocks() as demo:
|
|
279 |
view_db_btn.click(fn=view_db_interface, inputs=[], outputs=[db_output])
|
280 |
|
281 |
with gr.Column():
|
282 |
-
download_choice = gr.Radio(["Database (.db)", "
|
283 |
download_btn = gr.Button("Download")
|
284 |
download_output = gr.File(label="Download File")
|
285 |
|
|
|
205 |
if choice == "Database (.db)":
|
206 |
# Provide the path to the database file
|
207 |
return 'results.db'
|
208 |
+
elif choice == "Database (.html)":
|
209 |
conn = sqlite3.connect('results.db')
|
210 |
+
df = pd.read_sql_query("SELECT * FROM results", conn)
|
|
|
|
|
211 |
conn.close()
|
212 |
+
|
213 |
+
# Save the DataFrame as an HTML file
|
214 |
+
html_file_path = "/mnt/data/results.html"
|
215 |
+
df.to_html(html_file_path, index=False)
|
216 |
+
|
217 |
+
return html_file_path
|
|
|
|
|
218 |
|
219 |
# Initialize the database
|
220 |
init_db()
|
|
|
248 |
with gr.Column():
|
249 |
gr.Markdown("# Cataract Detection System")
|
250 |
gr.Markdown("Upload an image to detect cataract and add patient details.")
|
|
|
251 |
gr.Markdown("This application uses YOLOv8 with mAP=0.981")
|
252 |
|
253 |
with gr.Column():
|
|
|
274 |
view_db_btn.click(fn=view_db_interface, inputs=[], outputs=[db_output])
|
275 |
|
276 |
with gr.Column():
|
277 |
+
download_choice = gr.Radio(["Database (.db)", "Database (.html)"], label="Choose the file to download:")
|
278 |
download_btn = gr.Button("Download")
|
279 |
download_output = gr.File(label="Download File")
|
280 |
|