Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -48,14 +48,21 @@ def procesar_video(video):
|
|
48 |
if frame_count == 0:
|
49 |
raise gr.Error("No se pudieron extraer fotogramas del video")
|
50 |
|
51 |
-
# Crear collage de 4 fotogramas aleatorios
|
52 |
selected_frames = random.sample(frame_paths, min(4, len(frame_paths)))
|
53 |
images = [Image.open(img) for img in selected_frames]
|
54 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
for i, img in enumerate(images):
|
56 |
-
|
57 |
-
col = i % 2
|
58 |
-
collage.paste(img, (col * images[0].width, row * images[0].height))
|
59 |
collage_path = os.path.join(temp_dir, "collage.jpg")
|
60 |
collage.save(collage_path)
|
61 |
|
@@ -134,7 +141,8 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
134 |
|
135 |
with gr.Row():
|
136 |
with gr.Column():
|
137 |
-
|
|
|
138 |
# Ambos botones inician desactivados
|
139 |
procesar_btn = gr.Button("Procesar Fotogramas", interactive=False)
|
140 |
with gr.Column():
|
@@ -186,9 +194,12 @@ with gr.Blocks(title="Extracci贸n de Fotogramas Forenses") as demo:
|
|
186 |
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state, download_btn, procesar_btn],
|
187 |
)
|
188 |
|
189 |
-
#
|
|
|
|
|
|
|
190 |
download_btn.click(
|
191 |
-
fn=
|
192 |
inputs=zip_path_state,
|
193 |
outputs=download_file,
|
194 |
)
|
|
|
48 |
if frame_count == 0:
|
49 |
raise gr.Error("No se pudieron extraer fotogramas del video")
|
50 |
|
51 |
+
# Crear collage de 4 fotogramas aleatorios con separaci贸n
|
52 |
selected_frames = random.sample(frame_paths, min(4, len(frame_paths)))
|
53 |
images = [Image.open(img) for img in selected_frames]
|
54 |
+
margin = 10
|
55 |
+
collage_width = images[0].width * 2 + margin
|
56 |
+
collage_height = images[0].height * 2 + margin
|
57 |
+
collage = Image.new('RGB', (collage_width, collage_height), color=(255,255,255))
|
58 |
+
positions = [
|
59 |
+
(0, 0),
|
60 |
+
(images[0].width + margin, 0),
|
61 |
+
(0, images[0].height + margin),
|
62 |
+
(images[0].width + margin, images[0].height + margin)
|
63 |
+
]
|
64 |
for i, img in enumerate(images):
|
65 |
+
collage.paste(img, positions[i])
|
|
|
|
|
66 |
collage_path = os.path.join(temp_dir, "collage.jpg")
|
67 |
collage.save(collage_path)
|
68 |
|
|
|
141 |
|
142 |
with gr.Row():
|
143 |
with gr.Column():
|
144 |
+
# Desactivar opciones de webcam y edici贸n (tijera) estableciendo source="upload"
|
145 |
+
video_input = gr.Video(source="upload", label="Subir Video (solo archivos de video)", interactive=True)
|
146 |
# Ambos botones inician desactivados
|
147 |
procesar_btn = gr.Button("Procesar Fotogramas", interactive=False)
|
148 |
with gr.Column():
|
|
|
194 |
outputs=[gallery_output, download_file, temp_dir_state, zip_path_state, download_btn, procesar_btn],
|
195 |
)
|
196 |
|
197 |
+
# Funci贸n para activar la descarga: actualiza el componente File con la ruta del ZIP y lo hace visible
|
198 |
+
def trigger_download(zip_path):
|
199 |
+
return gr.update(value=zip_path, visible=True)
|
200 |
+
|
201 |
download_btn.click(
|
202 |
+
fn=trigger_download,
|
203 |
inputs=zip_path_state,
|
204 |
outputs=download_file,
|
205 |
)
|