Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -118,6 +118,7 @@ def procesar_video(video):
|
|
118 |
final_zip_path = os.path.join(temp_dir, zip_filename)
|
119 |
with open(final_zip_path, "wb") as f:
|
120 |
f.write(final_zip_data2)
|
|
|
121 |
# ===============================
|
122 |
|
123 |
return collage_path, final_zip_path, temp_dir
|
@@ -179,6 +180,7 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
179 |
limpiar_cache(temp_dir_state.value)
|
180 |
collage_path, zip_path, temp_dir = procesar_video(video)
|
181 |
btn_download_update = gr.update(interactive=True)
|
|
|
182 |
return collage_path, zip_path, temp_dir, zip_path, btn_download_update, btn_proc_update
|
183 |
|
184 |
procesar_btn.click(
|
@@ -187,9 +189,11 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
187 |
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state, download_btn, procesar_btn],
|
188 |
)
|
189 |
|
190 |
-
# Soluci贸n para que el bot贸n de descarga retorne la ruta del ZIP
|
191 |
def trigger_download(zip_path):
|
192 |
-
|
|
|
|
|
|
|
193 |
|
194 |
download_btn.click(
|
195 |
fn=trigger_download,
|
|
|
118 |
final_zip_path = os.path.join(temp_dir, zip_filename)
|
119 |
with open(final_zip_path, "wb") as f:
|
120 |
f.write(final_zip_data2)
|
121 |
+
final_zip_path = os.path.abspath(final_zip_path)
|
122 |
# ===============================
|
123 |
|
124 |
return collage_path, final_zip_path, temp_dir
|
|
|
180 |
limpiar_cache(temp_dir_state.value)
|
181 |
collage_path, zip_path, temp_dir = procesar_video(video)
|
182 |
btn_download_update = gr.update(interactive=True)
|
183 |
+
# Se retorna zip_path tanto para actualizar el estado como para asignar el valor al componente de descarga
|
184 |
return collage_path, zip_path, temp_dir, zip_path, btn_download_update, btn_proc_update
|
185 |
|
186 |
procesar_btn.click(
|
|
|
189 |
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state, download_btn, procesar_btn],
|
190 |
)
|
191 |
|
|
|
192 |
def trigger_download(zip_path):
|
193 |
+
# Se abre el archivo ZIP, se leen sus bytes y se retorna un par (nombre, contenido)
|
194 |
+
with open(zip_path, "rb") as f:
|
195 |
+
file_bytes = f.read()
|
196 |
+
return (os.path.basename(zip_path), file_bytes)
|
197 |
|
198 |
download_btn.click(
|
199 |
fn=trigger_download,
|