Update app.py
Browse files
app.py
CHANGED
|
@@ -295,20 +295,13 @@ def procesar_imagen(archivo_imagen):
|
|
| 295 |
info_metadatos += "- **Metadatos EXIF:** No se encontraron metadatos EXIF\r\n"
|
| 296 |
|
| 297 |
sha3_hash = calcular_hash(img)
|
| 298 |
-
info_metadatos += f"\r\n
|
| 299 |
|
| 300 |
manipulada, razones = analizar_manipulacion(img, metadatos)
|
| 301 |
info_manipulacion = "ANÁLISIS DE MANIPULACIÓN:\r\n\r\n"
|
| 302 |
info_manipulacion += f"- Porcentaje de áreas detectadas: {porcentaje_ela:.3f}%\r\n"
|
| 303 |
info_manipulacion += f"- Estimación forense: {probabilidad}\r\n\r\n"
|
| 304 |
|
| 305 |
-
if manipulada:
|
| 306 |
-
info_manipulacion += "⚠️ **LA IMAGEN HA SIDO MANIPULADA.**\r\n**Razones:**\r\n"
|
| 307 |
-
for r in razones:
|
| 308 |
-
info_manipulacion += f"- {r}\r\n"
|
| 309 |
-
else:
|
| 310 |
-
info_manipulacion += "✅ **LA IMAGEN NO HA SIDO MANIPULADA.**\r\n"
|
| 311 |
-
|
| 312 |
analysis_text = info_basica + info_metadatos + info_manipulacion
|
| 313 |
|
| 314 |
with open(text_path, "w", encoding="utf-8", newline="\r\n") as f:
|
|
@@ -361,16 +354,16 @@ with gr.Blocks(title="Análisis Forense de Imágenes con ELA", theme=theme, css=
|
|
| 361 |
with gr.Row():
|
| 362 |
with gr.Column():
|
| 363 |
input_image = gr.Image(
|
| 364 |
-
label="
|
| 365 |
type="filepath",
|
| 366 |
height=400,
|
| 367 |
sources=["upload"],
|
| 368 |
elem_classes=["equal-height"]
|
| 369 |
)
|
| 370 |
-
process_btn = gr.Button("
|
| 371 |
|
| 372 |
download_zip = gr.DownloadButton(
|
| 373 |
-
label="⬇️
|
| 374 |
variant="secondary",
|
| 375 |
visible=False,
|
| 376 |
interactive=True,
|
|
@@ -380,14 +373,14 @@ with gr.Blocks(title="Análisis Forense de Imágenes con ELA", theme=theme, css=
|
|
| 380 |
# Estadísticas en 2x2 grid
|
| 381 |
with gr.Row(visible=False) as stats_row:
|
| 382 |
with gr.Column():
|
| 383 |
-
stats_bar = gr.Plot(label="
|
| 384 |
-
stats_pie = gr.Plot(label="
|
| 385 |
with gr.Column():
|
| 386 |
-
stats_box = gr.Plot(label="
|
| 387 |
-
stats_scatter = gr.Plot(label="
|
| 388 |
|
| 389 |
with gr.Column():
|
| 390 |
-
with gr.Accordion("
|
| 391 |
ela_image = gr.Image(
|
| 392 |
label="**🔍 ÁREAS TURQUESA = manipulaciones o borrados**",
|
| 393 |
type="numpy",
|
|
@@ -396,9 +389,9 @@ with gr.Blocks(title="Análisis Forense de Imágenes con ELA", theme=theme, css=
|
|
| 396 |
elem_classes=["equal-height"]
|
| 397 |
)
|
| 398 |
|
| 399 |
-
with gr.Accordion("
|
| 400 |
-
analysis_text = gr.Textbox(label="
|
| 401 |
-
google_maps_btn = gr.Button("📍
|
| 402 |
google_maps_url_state = gr.State("")
|
| 403 |
|
| 404 |
def reset_on_upload():
|
|
|
|
| 295 |
info_metadatos += "- **Metadatos EXIF:** No se encontraron metadatos EXIF\r\n"
|
| 296 |
|
| 297 |
sha3_hash = calcular_hash(img)
|
| 298 |
+
info_metadatos += f"\r\n SHA3-256: {sha3_hash}\r\n\r\n"
|
| 299 |
|
| 300 |
manipulada, razones = analizar_manipulacion(img, metadatos)
|
| 301 |
info_manipulacion = "ANÁLISIS DE MANIPULACIÓN:\r\n\r\n"
|
| 302 |
info_manipulacion += f"- Porcentaje de áreas detectadas: {porcentaje_ela:.3f}%\r\n"
|
| 303 |
info_manipulacion += f"- Estimación forense: {probabilidad}\r\n\r\n"
|
| 304 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 305 |
analysis_text = info_basica + info_metadatos + info_manipulacion
|
| 306 |
|
| 307 |
with open(text_path, "w", encoding="utf-8", newline="\r\n") as f:
|
|
|
|
| 354 |
with gr.Row():
|
| 355 |
with gr.Column():
|
| 356 |
input_image = gr.Image(
|
| 357 |
+
label="Subir imagen (JPG/PNG)",
|
| 358 |
type="filepath",
|
| 359 |
height=400,
|
| 360 |
sources=["upload"],
|
| 361 |
elem_classes=["equal-height"]
|
| 362 |
)
|
| 363 |
+
process_btn = gr.Button("Analizar imagen", variant="primary")
|
| 364 |
|
| 365 |
download_zip = gr.DownloadButton(
|
| 366 |
+
label="⬇️ Descargar resultados (ZIP)",
|
| 367 |
variant="secondary",
|
| 368 |
visible=False,
|
| 369 |
interactive=True,
|
|
|
|
| 373 |
# Estadísticas en 2x2 grid
|
| 374 |
with gr.Row(visible=False) as stats_row:
|
| 375 |
with gr.Column():
|
| 376 |
+
stats_bar = gr.Plot(label="Porcentaje de Manipulación", show_label=True)
|
| 377 |
+
stats_pie = gr.Plot(label="Nivel de Probabilidad", show_label=True)
|
| 378 |
with gr.Column():
|
| 379 |
+
stats_box = gr.Plot(label="Distribución de Anomalías", show_label=True)
|
| 380 |
+
stats_scatter = gr.Plot(label="Análisis de Componentes", show_label=True)
|
| 381 |
|
| 382 |
with gr.Column():
|
| 383 |
+
with gr.Accordion("Resultado del Análisis ELA", open=True):
|
| 384 |
ela_image = gr.Image(
|
| 385 |
label="**🔍 ÁREAS TURQUESA = manipulaciones o borrados**",
|
| 386 |
type="numpy",
|
|
|
|
| 389 |
elem_classes=["equal-height"]
|
| 390 |
)
|
| 391 |
|
| 392 |
+
with gr.Accordion("Informe Detallado", open=True):
|
| 393 |
+
analysis_text = gr.Textbox(label="📝 Resultados del análisis forense", lines=15, max_lines=25)
|
| 394 |
+
google_maps_btn = gr.Button("📍 Ver ubicación en Google Maps", visible=False)
|
| 395 |
google_maps_url_state = gr.State("")
|
| 396 |
|
| 397 |
def reset_on_upload():
|