Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -5,7 +5,6 @@ import random
|
|
5 |
import zipfile
|
6 |
from PIL import Image
|
7 |
from datetime import datetime
|
8 |
-
import io
|
9 |
import hashlib
|
10 |
|
11 |
def procesar_video(video):
|
@@ -103,21 +102,20 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
103 |
procesar_btn = gr.Button("Procesar Fotogramas", interactive=False)
|
104 |
with gr.Column():
|
105 |
gallery_output = gr.Image(label="Collage de Muestra")
|
106 |
-
|
107 |
-
download_file = gr.File(label="Archivo ZIP generado", visible=True) # Cambiado a visible
|
108 |
|
109 |
temp_dir_state = gr.State(None)
|
110 |
zip_path_state = gr.State(None)
|
111 |
|
112 |
def on_video_change(video):
|
113 |
if video:
|
114 |
-
return gr.update(interactive=True)
|
115 |
-
return gr.update(interactive=False)
|
116 |
|
117 |
video_input.change(
|
118 |
fn=on_video_change,
|
119 |
inputs=video_input,
|
120 |
-
outputs=[procesar_btn
|
121 |
queue=False
|
122 |
)
|
123 |
|
@@ -125,26 +123,12 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
125 |
if temp_dir_state.value:
|
126 |
limpiar_cache(temp_dir_state.value)
|
127 |
collage_path, zip_path, temp_dir = procesar_video(video)
|
128 |
-
return collage_path, zip_path, temp_dir, zip_path
|
129 |
|
130 |
procesar_btn.click(
|
131 |
fn=procesar_y_mostrar,
|
132 |
inputs=video_input,
|
133 |
-
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state
|
134 |
-
)
|
135 |
-
|
136 |
-
def trigger_download(zip_path):
|
137 |
-
try:
|
138 |
-
with open(zip_path, "rb") as f:
|
139 |
-
file_bytes = f.read()
|
140 |
-
return os.path.basename(zip_path), file_bytes
|
141 |
-
except Exception as e:
|
142 |
-
raise gr.Error(f"Error al generar descarga: {str(e)}")
|
143 |
-
|
144 |
-
download_btn.click(
|
145 |
-
fn=trigger_download,
|
146 |
-
inputs=zip_path_state,
|
147 |
-
outputs=download_file,
|
148 |
)
|
149 |
|
150 |
if __name__ == "__main__":
|
|
|
5 |
import zipfile
|
6 |
from PIL import Image
|
7 |
from datetime import datetime
|
|
|
8 |
import hashlib
|
9 |
|
10 |
def procesar_video(video):
|
|
|
102 |
procesar_btn = gr.Button("Procesar Fotogramas", interactive=False)
|
103 |
with gr.Column():
|
104 |
gallery_output = gr.Image(label="Collage de Muestra")
|
105 |
+
download_file = gr.File(label="Archivo ZIP generado", visible=True) # Componente visible
|
|
|
106 |
|
107 |
temp_dir_state = gr.State(None)
|
108 |
zip_path_state = gr.State(None)
|
109 |
|
110 |
def on_video_change(video):
|
111 |
if video:
|
112 |
+
return gr.update(interactive=True)
|
113 |
+
return gr.update(interactive=False)
|
114 |
|
115 |
video_input.change(
|
116 |
fn=on_video_change,
|
117 |
inputs=video_input,
|
118 |
+
outputs=[procesar_btn],
|
119 |
queue=False
|
120 |
)
|
121 |
|
|
|
123 |
if temp_dir_state.value:
|
124 |
limpiar_cache(temp_dir_state.value)
|
125 |
collage_path, zip_path, temp_dir = procesar_video(video)
|
126 |
+
return collage_path, zip_path, temp_dir, zip_path
|
127 |
|
128 |
procesar_btn.click(
|
129 |
fn=procesar_y_mostrar,
|
130 |
inputs=video_input,
|
131 |
+
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
)
|
133 |
|
134 |
if __name__ == "__main__":
|