CoolFace
Apppublic

ReshanthGamiles/IMAGEFORENSICS

sourceHugging Faceapache-2.0updated 6mo agoView on Hugging Face
0likes
App README

πŸ”¬ Deep Forensics β€” Copy-Move Image Forgery Detection

A Flask web application that detects copy-move forgery in images using OpenCV (SIFT/ORB) feature extraction and Scikit-learn DBSCAN clustering.


✨ Features

FeatureDescription
Single Image AnalysisUpload an image, detect copy-move forgery with confidence scoring
Batch ProcessingAnalyze multiple images at once with per-image results
Analysis HistoryView past analyses with timestamps and download reports
EXIF Metadata AnalysisDetect editing software, date mismatches, GPS data
Dark / Light ModeToggle between themes with localStorage persistence
Detailed ReportsSeverity ratings, animated confidence gauge, downloadable reports

πŸ“ Project Structure

deep_forensics/
β”œβ”€β”€ app.py                  # Flask main application (history, batch, metadata, reports)
β”œβ”€β”€ detector.py             # Core SIFT/ORB detection algorithm
β”œβ”€β”€ requirements.txt        # Python dependencies
β”œβ”€β”€ templates/
β”‚   └── index.html          # Web UI (tabs, dark mode, batch, history)
β”œβ”€β”€ static/
β”‚   β”œβ”€β”€ uploads/            # Uploaded images (auto-created)
β”‚   └── results/            # Annotated result images (auto-created)
β”œβ”€β”€ create_test_image.py    # Generate a test forged image
β”œβ”€β”€ demo.py                 # CLI demo script
β”œβ”€β”€ run_dev.bat             # Windows batch launcher
└── run_dev.ps1             # PowerShell dev script

βš™οΈ Setup Instructions

Step 1 β€” Prerequisites

Make sure you have Python 3.8+ installed.

Step 2 β€” Create Virtual Environment

bash
python -m venv venv
venv\Scripts\activate        # Windows
source venv/bin/activate     # macOS / Linux

Step 3 β€” Install Dependencies

bash
pip install -r requirements.txt

Step 4 β€” Run the App

bash
python app.py

Open your browser at: http://127.0.0.1:5000


πŸš€ How It Works

StepProcess
1Upload a suspicious image via the web UI
2SIFT/ORB keypoints are extracted from the image
3Feature descriptors are matched across all image regions
4Suspicious pairs (spatially separated but visually identical) are filtered
5DBSCAN clusters the suspicious regions
6Annotated result highlights forged regions with confidence & severity

πŸ”Œ API Endpoints

MethodEndpointDescription
GET/Web UI
POST/analyzeAnalyze single image
POST/analyze-batchAnalyze multiple images
POST/metadataExtract EXIF metadata
GET/historyGet analysis history
DELETE/historyClear history
GET/report/<id>Download analysis report
GET/healthServer health check

πŸ§ͺ Test with a Forged Image

bash
python create_test_image.py
python demo.py

Or invoke the detector from CLI:

bash
python detector.py path/to/image.jpg -m SIFT

πŸ“Έ Supported Formats

JPG, JPEG, PNG, BMP, TIFF, WEBP (Max 16MB)


πŸ‘¨β€πŸ’» Technologies Used

  • β€”Python 3.x β€” Backend language
  • β€”Flask β€” Web framework
  • β€”OpenCV β€” Image processing + SIFT/ORB feature detection
  • β€”Scikit-learn β€” DBSCAN clustering
  • β€”Pillow β€” EXIF metadata extraction
  • β€”NumPy β€” Array operations
  • β€”MediaPipe β€” Face mesh landmarks for deepfake detection
  • β€”HTML/CSS/JS β€” Frontend UI with dark/light mode

🎭 Deepfake Detection

A brand‑new deepfake module analyzes both images and videos via facial landmark heuristics.

Features:

  • β€”Supports face JPG/PNG uploads and MP4/WebM/MOV videos
  • β€”Uses MediaPipe face mesh for landmark extraction
  • β€”Computes eye aspect ratio variance and other metrics
  • β€”Provides overlay visuals showing detected landmarks
  • β€”Includes API endpoint /api/detect-deepfake for programmatic access
  • β€”Results saved to history when logged in

Update your environment after editing requirements.txt and restart the server to enable deepfake functionality.