uoft-cs/cifar10
Viewer β’ Updated β’ 60k β’ 178k β’ 107
This model detects AI-generated images using Deep Support Vector Data Description (SVDD), a one-class learning approach. It was trained exclusively on real images to learn what "real" looks like, allowing it to identify synthetic/AI-generated images as anomalies.
| Metric | Value |
|---|---|
| Test Loss | 0.7637 |
| Mean Distance | 0.7637 |
| Std Distance | 0.0024 |
| 95th Percentile | 0.7700 |
| Radius Threshold | 0.7747 |
pip install torch torchvision pytorch-lightning huggingface-hub pillow
import torch
from huggingface_hub import hf_hub_download
from PIL import Image
import torchvision.transforms as transforms
# Download model
model_path = hf_hub_download(
repo_id="ash12321/ai-image-detector-deepsvdd",
filename="model.ckpt"
)
# Load model (you'll need the model class definition)
from model import AdvancedDeepSVDD
model = AdvancedDeepSVDD.load_from_checkpoint(model_path)
model.eval()
# Prepare image
transform = transforms.Compose([
transforms.Resize((32, 32)),
transforms.ToTensor(),
transforms.Normalize(
mean=[0.4914, 0.4822, 0.4465],
std=[0.2470, 0.2435, 0.2616]
)
])
image = Image.open('test_image.jpg').convert('RGB')
image_tensor = transform(image).unsqueeze(0)
# Predict
is_fake, scores, distances = model.predict_anomaly(image_tensor)
print(f"AI-Generated: {is_fake[0].item()}")
print(f"Confidence: {scores[0].item()*100:.1f}%")
print(f"Anomaly Score: {scores[0].item():.4f}")
import gradio as gr
def predict(image):
img_tensor = transform(image).unsqueeze(0)
is_fake, scores, _ = model.predict_anomaly(img_tensor)
result = "π¨ AI-Generated" if is_fake[0] else "β
Real Image"
confidence = f"{scores[0].item()*100:.1f}%"
return f"**{result}** (Confidence: {confidence})"
demo = gr.Interface(
fn=predict,
inputs=gr.Image(type="pil"),
outputs=gr.Markdown(),
title="AI Image Detector"
)
demo.launch()
Input (3x32x32)
β Stem Conv (64 channels)
β Layer1 (64β128) + Channel Attention
β Layer2 (128β256) + Channel Attention
β Layer3 (256β512) + Channel Attention
β Dual Pooling (Avg + Max)
β Projection Head (1024β512β128)
β Output (128-dim latent space)
Model Parameters: 5.3M trainable
Epochs: 30
Training Samples: 35,000 (70%)
Validation Samples: 7,500 (15%)
Test Samples: 7,500 (15%)
Precision: 16-bit mixed precision
GPU: NVIDIA L4 with Tensor Cores
Training Augmentations:
Validation/Test:
If you use this model in your research, please cite:
@misc{ai-image-detector-deepsvdd-2024,
author = {ash12321},
title = {AI Image Detector using Deep SVDD},
year = {2024},
publisher = {Hugging Face},
howpublished = {\url{https://huggingface.co/ash12321/ai-image-detector-deepsvdd}},
}
This model is released under the MIT License.
Contributions, issues, and feature requests are welcome!
ash12321