Downloads · 30 days
55
33% of all-time downloads
ash12321/deepfake-autoencoder-cifar10-v2
deepfake-autoencoder-cifar10-v2 is a machine learning model from ash12321. Use it for the machine learning task on the model card, and read the license before you ship it in a product.
Multi-dataset trained model with 19.18x separation between real and fake images.
Downloads · 30 days
55
33% of all-time downloads
All-time downloads
168
Public
Repo size
838 MB
Likes
0
Public
Click a slice to open those files.
.ckpt837 MB · 100%
From the Hugging Face model README
Multi-dataset trained model with 19.18x separation between real and fake images.
from huggingface_hub import hf_hub_download
import torch
from model import ResidualConvAutoencoder
from torchvision import transforms
from PIL import Image
import json
# Download model and thresholds
checkpoint_path = hf_hub_download(
repo_id="ash12321/deepfake-autoencoder-cifar10-v2",
filename="model_universal_best.ckpt"
)
threshold_path = hf_hub_download(
repo_id="ash12321/deepfake-autoencoder-cifar10-v2",
filename="thresholds_calibrated.json"
)
# Load model
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
model = ResidualConvAutoencoder(latent_dim=512, dropout=0.1).to(device)
checkpoint = torch.load(checkpoint_path, map_location=device)
model.load_state_dict(checkpoint['model_state_dict'])
model.eval()
# Load thresholds
with open(threshold_path) as f:
thresholds = json.load(f)
# Prepare image
transform = transforms.Compose([
transforms.Resize((128, 128)),
transforms.ToTensor(),
transforms.Normalize(mean=[0.5, 0.5, 0.5], std=[0.5, 0.5, 0.5])
])
image = Image.open("your_image.jpg").convert('RGB')
image_tensor = transform(image).unsqueeze(0).to(device)
# Get reconstruction error
with torch.no_grad():
error = model.reconstruction_error(image_tensor)
error_value = error.item()
print(f"Reconstruction error: {error_value:.6f}")
# Check against threshold (balanced mode)
balanced_threshold = thresholds['reconstruction_thresholds']['thresholds']['balanced']['value']
if error_value > balanced_threshold:
print("⚠️ Potential deepfake detected!")
else:
print("✅ Image appears authentic")
Three calibrated threshold levels:
| Mode | Threshold | False Positive Rate | Description |
|---|---|---|---|
| Strict | 0.055737 | ~1% | Very low false positives |
| Balanced | 0.039442 | ~5% | Recommended for general use |
| Sensitive | ~0.039 | ~2.5% | More sensitive detection |
Separation Ratio: 19.18x 🎯
model_universal_best.ckpt - Full checkpoint (418MB)thresholds_calibrated.json - Calibrated thresholdsmodel.py - Model architectureconfig.json - Training configurationREADME.md - This file@misc{deepfake_autoencoder_2024,
title={Residual Convolutional Autoencoder for Deepfake Detection},
author={Your Name},
year={2024},
publisher={HuggingFace},
url={https://huggingface.co/ash12321/deepfake-autoencoder-cifar10-v2}
}
MIT License