A comprehensive web application for detecting deepfakes and AI-generated images using a multi-layer authentication system. Protect yourself from impersonation and unauthorized use of your likeness.
- Invisible Watermarking: Embed robust watermarks using dwtDct method
- Facial Embedding Storage: 128-dimensional facial feature vectors using Facenet
- Digital Certificates: JSON certificates with SHA-256 hashes for verification
- Watermark Detection: Check for FaceGuard protection watermarks
- Facial Biometric Matching: Compare against registered user embeddings
- Deepfake Analysis: Detect manipulation artifacts and GAN signatures
- SynthID Detection: Identify Google Gemini/Imagen generated images
- Professional PDF reports for legal takedown requests
- Trust score visualization
- Legal notice templates
- Complete analysis documentation
faceguard/
├── backend/ # FastAPI Python backend
│ ├── main.py # API endpoints
│ ├── models/ # ML models (SynthID, DeepFace, Deepfake)
│ ├── services/ # Business logic
│ ├── database/ # SQLAlchemy models
│ └── utils/ # Helper functions
├── frontend/ # React + TypeScript frontend
│ ├── src/
│ │ ├── components/ # React components
│ │ ├── api/ # API client
│ │ └── types/ # TypeScript definitions
│ └── public/
└── README.md
- Python 3.10+
- Node.js 18+
- Git
cd faceguard/backend
# Create virtual environment
python -m venv venv
# Activate (Windows)
venv\Scripts\activate
# Activate (macOS/Linux)
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Run the server
uvicorn main:app --reload --host 0.0.0.0 --port 8000cd faceguard/frontend
# Install dependencies
npm install
# Run development server
npm run dev- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Docs: http://localhost:8000/docs
GET /api/healthPOST /api/protect
Content-Type: multipart/form-data
image: File
email: stringResponse:
{
"success": true,
"user_id": "uuid",
"protected_image_url": "/downloads/protected_xxx.png",
"certificate": {
"user_id": "uuid",
"original_hash": "sha256...",
"embedding_stored": true,
"watermark_key": "derived_key...",
"timestamp": "2026-01-22T10:30:00Z"
}
}POST /api/analyze
Content-Type: multipart/form-data
image: File
email: string (optional)Response:
{
"success": true,
"analysis_id": "uuid",
"results": {
"watermark": {
"present": false,
"owner_id": null
},
"face_match": {
"similarity": 0.87,
"matched_user": "user@example.com",
"is_match": true
},
"deepfake": {
"confidence": 0.92,
"likely_fake": true,
"model_used": "HeuristicAnalyzer"
},
"synthid": {
"is_synthetic": true,
"confidence": 0.94,
"source": "gemini"
},
"trust_score": 0,
"verdict": "HIGHLY SUSPICIOUS"
},
"evidence_report_url": "/api/reports/uuid.pdf"
}GET /api/reports/{analysis_id}.pdf- Uses invisible-watermark library with dwtDct encoding
- Survives JPEG compression and screenshots (~80% survival rate)
- Payload:
USER:{user_id}|TIME:{timestamp}
- DeepFace with Facenet model (128-d vectors)
- Cosine similarity comparison
- Threshold: 0.85 for positive match
- Frequency analysis (FFT for GAN artifacts)
- Color consistency checks (LAB color space)
- Texture analysis (Laplacian variance)
- Edge pattern analysis (Canny edge detection)
- Uses
google/synthid-image-detectorfrom Hugging Face - Specifically detects Gemini/Imagen generated images
- Binary classification with confidence score
def calculate_trust_score(watermark_present, face_similarity, deepfake_conf, synthid_detected):
score = 100
if not watermark_present:
score -= 30
if face_similarity > 0.85:
score -= 25
if deepfake_conf > 0.80:
score -= 25
if synthid_detected:
score -= 20
return max(0, score)| Score Range | Verdict |
|---|---|
| 80-100 | LIKELY AUTHENTIC |
| 60-79 | UNCERTAIN |
| 40-59 | SUSPICIOUS |
| 20-39 | LIKELY FAKE |
| 0-19 | HIGHLY SUSPICIOUS |
- Dark Mode: Modern dark theme with light mode toggle
- Drag & Drop: Smooth file upload experience
- Progress Indicators: Real-time processing status
- Animated Trust Gauge: Visual score representation
- Responsive Design: Mobile-friendly layout
- All facial embeddings are stored as encrypted blobs
- Watermark keys are derived from hashed emails
- No raw images are stored after processing
- CORS configured for localhost only in development
- FastAPI + Uvicorn
- SQLAlchemy (SQLite)
- invisible-watermark
- DeepFace + TensorFlow
- Transformers + PyTorch
- ReportLab (PDF generation)
- OpenCV + Pillow
- React 18 + TypeScript
- Tailwind CSS
- Axios
- React Dropzone
- Recharts
- Lucide Icons
# Protect an image
response = requests.post('/api/protect', files={'image': img}, data={'email': 'test@example.com'})
# Download and analyze
response = requests.post('/api/analyze', files={'image': protected_img})
assert response.json()['results']['watermark']['present'] == True# Upload photo 1
response1 = requests.post('/api/protect', files={'image': photo1}, data={'email': 'user@example.com'})
# Analyze photo 2 of same person
response2 = requests.post('/api/analyze', files={'image': photo2}, data={'email': 'user@example.com'})
assert response2.json()['results']['face_match']['similarity'] > 0.85- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit changes (
git commit -m 'Add amazing feature') - Push to branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google's SynthID for AI-generated image detection
- DeepFace library for facial recognition
- invisible-watermark for robust watermarking
- Hugging Face for model hosting
Built with ❤️ for K-Hacks 2026
FaceGuard - Protecting digital dignity against deepfakes and AI impersonation 🛡️