Spaces:
Paused
Paused
Commit ·
a5c0306
1
Parent(s): fba59bc
fix(deploy): enforce memory-safe spatial-FFT deepfake detector in containers to prevent 512MB OOM crash
Browse filesFiles changed (3)
3 unmodified lines4567893 unmodified lines# Suppress pip root user warnings in DockerENV PIP_ROOT_USER_ACTION=ignore# Install system dependencies for OpenCV and networkingRUN apt-get update && apt-get install -y --no-install-recommends \3 unmodified lines45678910113 unmodified lines# Suppress pip root user warnings in DockerENV PIP_ROOT_USER_ACTION=ignore# Memory-conserving mode for cloud free tier containers (<= 512MB RAM)ENV ENABLE_VIT_MODEL=false# Install system dependencies for OpenCV and networkingRUN apt-get update && apt-get install -y --no-install-recommends \
12322 unmodified lines262728293031import loggingfrom pathlib import Pathfrom typing import Union, Dict, Any, Optional22 unmodified linesif self._load_attempted:returnself._load_attempted = Truetry:from transformers import AutoImageProcessor, AutoModelForImageClassificationimport torch123422 unmodified lines272829303132333435363738394041424344454647484950import osimport loggingfrom pathlib import Pathfrom typing import Union, Dict, Any, Optional22 unmodified linesif self._load_attempted:returnself._load_attempted = True# Memory conservation safeguard for cloud free tiers (e.g. Render 512MB RAM)enable_vit = os.getenv("ENABLE_VIT_MODEL", "").lower()if enable_vit == "false":logger.info("ViT model disabled via ENABLE_VIT_MODEL=false. Using lightweight spatial-FFT detector.")self._available = Falsereturnelif enable_vit != "true":try:import psutiltotal_mb = psutil.virtual_memory().total / (1024 * 1024)if total_mb < 1200:logger.info("Host memory is %.0f MB (< 1200 MB). Using lightweight spatial-FFT detector to protect container stability.", total_mb)self._available = Falsereturnexcept Exception:passtry:from transformers import AutoImageProcessor, AutoModelForImageClassificationimport torch
1230 unmodified lines123112321233123412351230 unmodified lines},"previous_hash": "f0b09b09a2d9c870c18c19f4150c556b69837f1ab2355d125250e7eeb4811a11","hash": "79b0ecb7accd2580888ccb491311fae5d2df03d226addcacf1b3b6833179319d"}]1230 unmodified lines123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851230 unmodified lines},"previous_hash": "f0b09b09a2d9c870c18c19f4150c556b69837f1ab2355d125250e7eeb4811a11","hash": "79b0ecb7accd2580888ccb491311fae5d2df03d226addcacf1b3b6833179319d"},{"index": 11,"timestamp": 1788773609.0568485,"evidence_record": {"schema_version": "2.0","protocol": "FaceID forensic evidence","created_at": "2026-09-07T09:33:29.056289+00:00","source_image": {"filename": "sample.jpg","sha256": "954419c50ed11c9db3bd5453548eb1a2c39a967bfdc78dfc9e4f45a034d0ea3d","phash": "e959968619697996"},"image": {"filename": "sample.jpg","sha256": "954419c50ed11c9db3bd5453548eb1a2c39a967bfdc78dfc9e4f45a034d0ea3d","phash": "e959968619697996"},"biometrics": {"detected": false,"face_count": 0,"embedding_model": "ArcFace 512-d (buffalo_s)","embedding_persistent": false,"det_score": 0.0,"face_boxes": [],"landmarks": []},"face": {"detected": false,"count": 0,"embedding_generated": false,"det_score": 0.0,"face_boxes": [],"landmarks": []},"osint_search": {"provider": "SerpApi Google Lens","total_candidates": 2,"error": null},"reverse_search": {"provider": "SerpApi Google Lens","count": 2,"error": null},"best_match": {"title": "Rolling into a new era! Once Upon A KATAMARI out NOW on ...","source": "Instagram","link": "https://www.instagram.com/p/DQK_wc9iaHM/","platform": "Instagram","is_specific_post": true,"post_type": "Post","cosine_similarity": null,"visual_similarity": 0.3658,"phash_distance": 28,"verified": false},"deepfake_analysis": {"label": "Deepfake","risk_score": 0.6974,"confidence": 0.6974,"is_synthetic": true,"model": "prithivMLmods/Deep-Fake-Detector-v2-Model","status": "ANALYZED"},"verification": {"status": "NO_CONFIRMED_MATCH","best_similarity": 0.3658,"threshold": 0.9,"phash_max_distance": 12},"evidence_hash": "e25c3beaad64c475b3d01776509999fd392bb2f4477d9b6fe0a1d2568a863344"},"previous_hash": "79b0ecb7accd2580888ccb491311fae5d2df03d226addcacf1b3b6833179319d","hash": "ac012e7f1e6c3fe32f37621d492d30106d321b7fd44680b41c5fbb00037bbb65"},{"index": 12,"timestamp": 1788773744.7905204,"evidence_record": {"schema_version": "2.0","protocol": "FaceID forensic evidence","created_at": "2026-09-07T09:35:44.790021+00:00","source_image": {"filename": "sample.jpg","sha256": "954419c50ed11c9db3bd5453548eb1a2c39a967bfdc78dfc9e4f45a034d0ea3d","phash": "e959968619697996"},"image": {"filename": "sample.jpg","sha256": "954419c50ed11c9db3bd5453548eb1a2c39a967bfdc78dfc9e4f45a034d0ea3d","phash": "e959968619697996"},"biometrics": {"detected": false,"face_count": 0,"embedding_model": "ArcFace 512-d (buffalo_s)","embedding_persistent": false,"det_score": 0.0,"face_boxes": [],"landmarks": []},"face": {"detected": false,"count": 0,"embedding_generated": false,"det_score": 0.0,"face_boxes": [],"landmarks": []},"osint_search": {"provider": "SerpApi Google Lens","total_candidates": 2,"error": null},"reverse_search": {"provider": "SerpApi Google Lens","count": 2,"error": null},"best_match": {"title": "MANGORO - YouTube","source": "YouTube","link": "https://www.youtube.com/@mangoro_official","platform": "YouTube","is_specific_post": false,"post_type": "Generic Portal / Aggregator","cosine_similarity": null,"visual_similarity": 0.4478,"phash_distance": 20,"verified": false},"deepfake_analysis": {"label": "Authentic / Real","risk_score": 0.05,"confidence": 0.9,"is_synthetic": false,"model": "Spatial-FFT-Heuristic (Offline Fallback)","status": "ANALYZED"},"verification": {"status": "NO_CONFIRMED_MATCH","best_similarity": 0.4478,"threshold": 0.9,"phash_max_distance": 12},"evidence_hash": "bffde6f891773c39da9467c1014ac596011dda1a5e282d7f2773fe8bb6c89e9d"},"previous_hash": "ac012e7f1e6c3fe32f37621d492d30106d321b7fd44680b41c5fbb00037bbb65","hash": "2811693115f654795b8edbe36cbdd57e20dd75c4e30fb679adade8062a4e3373"}]
Dockerfile+2
app/deepfake/classifier.py+19
chain/blockchain.json+150