Spaces:
Sleeping
Sleeping
ariankhalfani
commited on
Commit
•
882c701
1
Parent(s):
657afd9
Update app.py
Browse files
app.py
CHANGED
@@ -152,12 +152,12 @@ def save_patient_info_to_html(name, age, medical_record, sex, result):
|
|
152 |
|
153 |
return html_file_path
|
154 |
|
155 |
-
# Function to download the folders
|
156 |
-
def download_folder(
|
157 |
-
zip_path = os.path.join(tempfile.gettempdir(), f"{
|
158 |
|
159 |
# Zip the folder
|
160 |
-
shutil.make_archive(zip_path.replace('.zip', ''), 'zip',
|
161 |
|
162 |
return zip_path
|
163 |
|
@@ -192,10 +192,11 @@ with gr.Blocks() as demo:
|
|
192 |
uploaded_folder_file = gr.File(label="Uploaded Images Zip File")
|
193 |
predicted_folder_file = gr.File(label="Predicted Images Zip File")
|
194 |
|
|
|
195 |
submit_btn.click(fn=predict_image, inputs=[name, age, medical_record, sex, input_image], outputs=[output_image, raw_result])
|
196 |
download_html_btn.click(fn=save_patient_info_to_html, inputs=[name, age, medical_record, sex, raw_result], outputs=patient_info_file)
|
197 |
-
download_uploaded_btn.click(fn=download_folder, inputs=[uploaded_folder], outputs=uploaded_folder_file)
|
198 |
-
download_predicted_btn.click(fn=download_folder, inputs=[predicted_folder], outputs=predicted_folder_file)
|
199 |
|
200 |
# Launch Gradio app
|
201 |
demo.launch()
|
|
|
152 |
|
153 |
return html_file_path
|
154 |
|
155 |
+
# Function to download the folders (fix: pass string path instead of Path object)
|
156 |
+
def download_folder(folder_path):
|
157 |
+
zip_path = os.path.join(tempfile.gettempdir(), f"{Path(folder_path).name}.zip")
|
158 |
|
159 |
# Zip the folder
|
160 |
+
shutil.make_archive(zip_path.replace('.zip', ''), 'zip', folder_path)
|
161 |
|
162 |
return zip_path
|
163 |
|
|
|
192 |
uploaded_folder_file = gr.File(label="Uploaded Images Zip File")
|
193 |
predicted_folder_file = gr.File(label="Predicted Images Zip File")
|
194 |
|
195 |
+
# Fix: pass string representation of Path objects
|
196 |
submit_btn.click(fn=predict_image, inputs=[name, age, medical_record, sex, input_image], outputs=[output_image, raw_result])
|
197 |
download_html_btn.click(fn=save_patient_info_to_html, inputs=[name, age, medical_record, sex, raw_result], outputs=patient_info_file)
|
198 |
+
download_uploaded_btn.click(fn=download_folder, inputs=[str(uploaded_folder)], outputs=uploaded_folder_file)
|
199 |
+
download_predicted_btn.click(fn=download_folder, inputs=[str(predicted_folder)], outputs=predicted_folder_file)
|
200 |
|
201 |
# Launch Gradio app
|
202 |
demo.launch()
|