king1oo1/deepfake-model
DeepGuard (Deepfake Model)
Model Overview
This is a fine-tuned version of `google/siglip2-base-patch16-224`, specifically trained for binary image classification to detect AI-generated and deepfake images. It is the core inference engine powering the DeepGuard AI Media Forensics App.
The model distinguishes between Real photographs and Fake (AI-generated or deepfake) images. By leveraging the powerful SigLIP2 vision-language encoder and training it on a diverse, multi-source dataset of over 330,000 images, this model demonstrates robust performance in identifying synthetic media, including outputs from modern generators like Midjourney, Stable Diffusion, and DALL·E.
Datasets
The model was trained on a carefully curated, balanced dataset of 40,000 images (20,000 real, 20,000 fake), sampled from five diverse, high-quality sources to ensure robustness and generalization across various forgery types.
Training Procedure
The model was fine-tuned using a progressive unfreezing strategy to adapt the pre-trained SigLIP2 encoder while preventing catastrophic forgetting. All training was performed on a Tesla T4 GPU in Google Colab.
Training Hyperparameters
- Batch Size: 32
- Optimizer: AdamW
- Scheduler: Cosine Annealing
- Loss Function: Cross-Entropy Loss
- Data Augmentation: Random Horizontal Flip, Random Rotation (10°), Color Jitter
Performance Metrics
Evaluation on a held-out validation set results:
Usage
You can load and use this model directly with the Hugging Face transformers library.
from transformers import AutoImageProcessor, AutoModelForImageClassification
from PIL import Image
import torch
# Load model and processor
model_name = "king1oo1/ai-vs-real-deepfake-model" # Replace with your actual model ID
processor = AutoImageProcessor.from_pretrained(model_name)
model = AutoModelForImageClassification.from_pretrained(model_name)
model.eval()
# Load and preprocess an image
image = Image.open("path/to/your/image.jpg").convert("RGB")
inputs = processor(images=image, return_tensors="pt")
# Run inference
with torch.no_grad():
outputs = model(**inputs)
probs = torch.softmax(outputs.logits, dim=1)
fake_prob = probs[0][1].item() * 100
real_prob = probs[0][0].item() * 100
print(f"Fake probability: {fake_prob:.2f}%")
print(f"Real probability: {real_prob:.2f}%")
print(f"Verdict: {'FAKE' if fake_prob > 50 else 'REAL'}")