# -*- coding: utf-8 -*- """ app.py — CrimeSceneSolver (Scene Solver v3) — Hugging Face Space ================================================================ Faithful port of the notebook's `demo_v2` application: the four-tab frontend (Home / Analyse / Sherl0ck Agent / Contact), the nine-stage SceneSolver pipeline, the Sherl0ck agentic escalation layer (Cohere reasoning + LFM2.5-Audio voice), evidence dispatch, incoming-call behaviour and the forensic PDF/JSON outputs. Deployment notes: * `import spaces` must run before scenesolver_core (ZeroGPU CUDA model). * GPU-heavy entry points are decorated with @spaces.GPU (dynamic duration). * All secrets (COHERE_API_KEY, TELEGRAM_*, DISCORD_WEBHOOK_URL, SMTP credentials) come from environment variables / Space secrets only. """ import spaces # noqa: F401 — must precede torch device selection (ZeroGPU) from scenesolver_core import ( # noqa: E402 AUDIOPATHS, Config, SceneSolverPipeline, frame_to_timestamp, get_pipeline, log, ) import gradio as gr import numpy as np import json, os, traceback, smtplib, ssl, re, base64 from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from PIL import Image # ───────────────────────────────────────────────────────────────────────────── # SHARED CONSTANTS (used by both the web app and the agent layer) # ───────────────────────────────────────────────────────────────────────────── ADMIN_EMAIL = os.environ.get("ADMIN_EMAIL", "anumulasamarth008@gmail.com") SMTP_SERVER = "smtp.gmail.com" SMTP_PORT = 465 SENDER_EMAIL = os.environ.get("SENDER_EMAIL", "") SENDER_PASS = os.environ.get("SENDER_PASS", "") # Design tokens — pitch black / white / orange-saffron C_BG = "#000000" C_ORANGE = "#FF8C00" C_RED = "#FF4500" C_GREEN = "#4CAF50" # Shared HTML blocks NAV_HTML = """
DISCLAIMER — This report is produced by machine learning models and should be treated as an investigative aid, not a definitive conclusion. Human expert review is strongly recommended before any operational action is taken.
CrimeSceneSolver is an end-to-end forensic intelligence platform. Upload CCTV footage and a nine-stage AI pipeline analyses it, then Sherl𝟬ck, the agentic escalation layer, briefs you by voice or text, dispatches evidence to all channels, and generates a full PDF dossier.
“We closed a complex six-month investigation in under two weeks after deploying SceneSolver. The nine-stage pipeline, Sherl0ck voice briefings, and automated evidence dispatch changed how our forensics team operates entirely.”
Upload CCTV footage to run the full nine-stage forensic pipeline.
Run an analysis on the Analyse tab first. After Accept Call, speak naturally — no push-to-talk. Text chat remains independent.
Reach out with questions, partnership inquiries, or case-specific requests.