Downloads · 30 days
5
5% of all-time downloads
ash12321/fake-image-detection-ensemble
fake-image-detection-ensemble is a image classification model from ash12321. Use it when you need a label for an image. The card lists the license as mit.
A powerful ensemble of 9 specialized models trained for detecting fake/AI-generated images using single-class anomaly detection. Trained only on real images to learn what "normal" looks like, then detects fakes as ano…
Downloads · 30 days
5
5% of all-time downloads
All-time downloads
95
Public
Repo size
417 MB
Likes
0
Public
Click a slice to open those files.
.pth262 MB · 63%
From the Hugging Face model README
A powerful ensemble of 9 specialized models trained for detecting fake/AI-generated images using single-class anomaly detection. Trained only on real images to learn what "normal" looks like, then detects fakes as anomalies.
| Metric | Score |
|---|---|
| Accuracy | 67.05% |
| Precision | 87.97% |
| Recall | 39.50% |
| F1 Score | 54.52% |
The ensemble combines 9 specialized models using different detection strategies:
Enhanced Frequency VAE - Multi-scale frequency analysis with phase information
Edge Normalizing Flow - Probability density estimation on edge features
Semantic Deep SVDD - ResNet50-based hypersphere anomaly detection
Texture One-Class SVM - Boundary-based detection
Isolation Forest - Isolation-based anomaly detection
Local Outlier Factor - Local density anomalies
Gaussian Mixture Model - Distribution modeling
Color Distribution Model - Statistical color analysis
Statistical Model - Edge and color statistics
import torch
from torchvision import transforms
from PIL import Image
import pickle
import json
from huggingface_hub import hf_hub_download
# Configuration
repo_id = "ash12321/fake-image-detection-ensemble"
device = 'cuda' if torch.cuda.is_available() else 'cpu'
# Download and load config
config_path = hf_hub_download(repo_id=repo_id, filename="config.json")
with open(config_path, 'r') as f:
config = json.load(f)
# Load models (you need the model class definitions)
# Example for one model:
vae_path = hf_hub_download(repo_id=repo_id, filename="freq_vae.pth")
# freq_vae = EnhancedFreqVAE()
# freq_vae.load_state_dict(torch.load(vae_path, map_location=device))
# freq_vae.to(device)
# Load all other models similarly...
# Predict on new image
img = Image.open('test_image.jpg')
img = img.resize((256, 256), Image.LANCZOS).convert('RGB')
tfm = transforms.Compose([
transforms.ToTensor(),
transforms.Normalize([0.485,0.456,0.406], [0.229,0.224,0.225])
])
img_tensor = tfm(img)
# Get prediction from ensemble
is_fake, score, individual_scores = ensemble.predict(img_tensor, device)
print(f"Prediction: {'FAKE' if is_fake else 'REAL'}")
print(f"Anomaly Score: {score:.4f}")
print(f"Individual model scores: {individual_scores}")
| File | Description | Size |
|---|---|---|
freq_vae.pth | Enhanced Frequency VAE weights | ~100 MB |
semantic_svdd.pth | Semantic Deep SVDD weights | ~90 MB |
edge_flow.pth | Edge Normalizing Flow weights | ~5 MB |
texture_ocsvm.pkl | Texture One-Class SVM | ~200 MB |
iforest.pkl | Isolation Forest | ~150 MB |
lof.pkl | Local Outlier Factor | ~180 MB |
gmm.pkl | Gaussian Mixture Model | ~50 MB |
color_model.pkl | Color Distribution Model | ~10 MB |
stat.pkl | Statistical Model | ~5 MB |
config.json | Ensemble configuration | <1 MB |
results_summary.json | Training metrics | <1 MB |
torch>=2.0.0
torchvision>=0.15.0
numpy>=1.24.0
pillow>=9.0.0
scikit-learn>=1.3.0
scipy>=1.10.0
huggingface_hub>=0.19.0
This version includes several accuracy enhancements:
@misc{fake-detection-ensemble-2024,
author = {ash12321},
title = {Fake Image Detection Ensemble - 9 Model System},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/ash12321/fake-image-detection-ensemble}}
}
MIT License - Free for research and commercial use
Questions? Issues? Open an issue or discussion on this repository!
Note: This model was trained using single-class learning, making it robust to new types of fake images not seen during training. The ensemble approach combines multiple detection strategies for maximum accuracy and reliability.