SDXL Detector (ResNet-50)
Model Description
A specialized deep learning model for detecting images generated by Stable Diffusion XL (SDXL) 1.0 at 1024×1024 resolution.
Architecture: ResNet-50 (pretrained on ImageNet, fine-tuned for SDXL detection)
Training Date: December 30, 2025
Purpose: This is a specialist model designed specifically for SDXL 1.0 detection. For general AI image detection across multiple generators, use this as part of an ensemble with other specialist models.
Performance Metrics
Test Set Results (2,856 images)
Metric Score Accuracy 99.75% F1 Score 99.77% Precision 99.61% Recall 99.93% AUC-ROC 0.9999 Average Precision 0.9999
Per-Class Performance
precision recall f1-score support
Real 99.92% 99.55% 99.73% 1,320
Fake 99.61% 99.93% 99.77% 1,536
Training Details
Total Epochs: 12
Final Training Accuracy: 99.92%
Final Validation Accuracy: 99.75%
Training Time: ~6 minutes on H100 GPU
Model Parameters: 24,559,170
Confusion Matrix
Out of 2,856 test images:
Real images (1,320): 1,314 correct, 6 misclassified
Fake images (1,536): 1,535 correct, 1 misclassified
Total errors: Only 7 images (0.25% error rate)
Intended Use
Primary Use Case
Detecting images generated by Stable Diffusion XL (SDXL) 1.0 at 1024×1024 resolution.
What This Model Can Do
✅ Detect SDXL 1.0 generated images with 99.75% accuracy
✅ Identify SDXL-specific generation patterns and artifacts
✅ Work with 1024×1024 SDXL outputs
What This Model Cannot Do
❌ Detect images from other generators (Midjourney, DALL-E, Flux, etc.)
❌ Work reliably on non-1024×1024 resolutions
❌ Detect other Stable Diffusion versions (1.5, 2.1, etc.)
Note: For comprehensive AI image detection across multiple generators, this model should be used as part of an ensemble with other specialist detectors.
Training Data
Real Images (9,034 total)
Food101: 2,000 images (food photography)
AFHQ: 2,000 images (animal faces)
Oxford Pets: 2,000 images (pet photography)
Stanford Cars: 2,000 images (vehicle photography)
Beans: 1,034 images (agricultural images)
All real images were resized to 1024×1024 to match SDXL output dimensions.
Fake Images (10,000 total)
Source: SDXL 1.0 generated images
Resolution: 1024×1024
Dataset: ash12321/sdxl-generated-10k
Data Split
Training: 70% (13,323 images)
Validation: 15% (2,855 images)
Test: 15% (2,856 images)
Model Architecture
Base Model: ResNet-50 (pretrained on ImageNet)
Custom Classifier Head:
1 Sequential (
2 Dropout ( p = 0.3 ) ,
3 Linear ( 2048 → 512 ) ,
4 BatchNorm1d ( 512 ) ,
5 ReLU ( ) ,
6 Dropout ( p = 0.15 ) ,
7 Linear ( 512 → 2 )
8 )
Input: RGB images resized to 224×224
Output: Binary classification (Real vs SDXL-generated)
Training Configuration
Hyperparameters
Optimizer: AdamW
Learning Rate: 0.001 (with cosine annealing)
Batch Size: 128
Weight Decay: 0.01
Dropout: 0.3
Label Smoothing: 0.05
Mixed Precision: bfloat16 (H100 optimized)
Augmentation (Training Only)
RandomResizedCrop (scale: 0.8-1.0)
RandomHorizontalFlip (p=0.5)
RandomRotation (±15°)
ColorJitter (brightness, contrast, saturation, hue)
Normalization (ImageNet stats)
Hardware
GPU: NVIDIA H100
Training Time: ~6 minutes
Inference Speed: ~4ms per image (H100)
Usage
Installation
pip install torch torchvision pillow huggingface_hub
Quick Start
1 import torch
2 from torchvision import transforms
3 from PIL import Image
4 from huggingface_hub import hf_hub_download
5
6 # Download model
7 model_path = hf_hub_download (
8 repo_id = "ash12321/sdxl-detector-resnet50" ,
9 filename = "best.pth"
10 )
11
12 # Load model
13 checkpoint = torch . load ( model_path , map_location = 'cpu' )
14
15 # Create model architecture
16 import torchvision . models as models
17 import torch . nn as nn
18
19 class SDXLDetector ( nn . Module ) :
20 def __init__ ( self ) :
21 super ( ) . __init__ ( )
22 self . backbone = models . resnet50 ( pretrained = False )
23 num_features = self . backbone . fc . in_features
24 self . backbone . fc = nn . Sequential (
25 nn . Dropout ( p = 0.3 ) ,
26 nn . Linear ( num_features , 512 ) ,
27 nn . BatchNorm1d ( 512 ) ,
28 nn . ReLU ( inplace = True ) ,
29 nn . Dropout ( p = 0.15 ) ,
30 nn . Linear ( 512 , 2 )
31 )
32
33 def forward ( self , x ) :
34 return self . backbone ( x )
35
36 # Initialize and load weights
37 model = SDXLDetector ( )
38 model . load_state_dict ( checkpoint [ 'model_state_dict' ] )
39 model . eval ( )
40
41 # Preprocessing
42 transform = transforms . Compose ( [
43 transforms . Resize ( 256 ) ,
44 transforms . CenterCrop ( 224 ) ,
45 transforms . ToTensor ( ) ,
46 transforms . Normalize (
47 mean = [ 0.485 , 0.456 , 0.406 ] ,
48 std = [ 0.229 , 0.224 , 0.225 ]
49 )
50 ] )
51
52 # Predict
53 image = Image . open ( "test_image.jpg" ) . convert ( 'RGB' )
54 input_tensor = transform ( image ) . unsqueeze ( 0 )
55
56 with torch . no_grad ( ) :
57 outputs = model ( input_tensor )
58 probs = torch . softmax ( outputs , dim = 1 )
59 prediction = torch . argmax ( probs , dim = 1 ) . item ( )
60 confidence = probs [ 0 ] [ prediction ] . item ( )
61
62 # Results
63 labels = [ 'Real' , 'SDXL-generated' ]
64 print ( f"Prediction: { labels [ prediction ] } " )
65 print ( f"Confidence: { confidence * 100 : .2f } %" )
Batch Prediction
1 from torch . utils . data import DataLoader , Dataset
2
3 class ImageDataset ( Dataset ) :
4 def __init__ ( self , image_paths , transform ) :
5 self . image_paths = image_paths
6 self . transform = transform
7
8 def __len__ ( self ) :
9 return len ( self . image_paths )
10
11 def __getitem__ ( self , idx ) :
12 image = Image . open ( self . image_paths [ idx ] ) . convert ( 'RGB' )
13 return self . transform ( image )
14
15 # Create dataset and loader
16 image_paths = [ 'image1.jpg' , 'image2.jpg' , . . . ]
17 dataset = ImageDataset ( image_paths , transform )
18 loader = DataLoader ( dataset , batch_size = 32 , num_workers = 4 )
19
20 # Batch inference
21 predictions = [ ]
22 confidences = [ ]
23
24 model . eval ( )
25 with torch . no_grad ( ) :
26 for batch in loader :
27 outputs = model ( batch )
28 probs = torch . softmax ( outputs , dim = 1 )
29 preds = torch . argmax ( probs , dim = 1 )
30 confs = torch . max ( probs , dim = 1 ) [ 0 ]
31
32 predictions . extend ( preds . cpu ( ) . numpy ( ) )
33 confidences . extend ( confs . cpu ( ) . numpy ( ) )
Limitations
Generator-Specific: Only trained on SDXL 1.0. Will not reliably detect:
Other Stable Diffusion versions (1.5, 2.1, 3.0)
Midjourney, DALL-E, Flux
Other generative models
Resolution-Specific: Optimized for 1024×1024 SDXL images. Performance may degrade on:
Lower resolutions
Higher resolutions
Non-square aspect ratios
Dataset Bias: Trained on specific real image categories (food, animals, vehicles, etc.). May perform differently on:
Artistic images
Abstract images
Specialized domains (medical, satellite, etc.)
Adversarial Attacks: Not hardened against adversarial perturbations
Ethical Considerations
Intended Applications
✅ Content moderation
✅ Academic research
✅ Digital forensics
✅ Media verification
Prohibited Uses
❌ Surveillance without consent
❌ Discrimination or profiling
❌ Bypassing content policies
False Positives/Negatives
False Positives (0.45%): Real images misclassified as SDXL-generated
May unfairly flag authentic content
Always provide human review for high-stakes decisions
False Negatives (0.07%): SDXL images misclassified as real
SDXL-generated content may slip through
Use as part of multi-layer verification
Transparency
This model should be deployed with clear communication to users about:
Its specific purpose (SDXL detection only)
Its limitations (not for other generators)
Confidence scores for each prediction
The possibility of errors
Citation
If you use this model in your research, please cite:
1 @misc{sdxl_detector_2024,
2 author = {Your Name},
3 title = {SDXL Detector: ResNet-50 Fine-tuned for SDXL Detection},
4 year = {2024},
5 publisher = {HuggingFace},
6 howpublished = {\url{https://huggingface.co/ash12321/sdxl-detector-resnet50}},
7 }
Model Card Authors
ash12321
Model Card Contact
For questions or issues, please open an issue on the model repository.
License
MIT License
Changelog
Version 1.0 (2025-12-30)
Initial release
99.75% test accuracy on SDXL detection
ResNet-50 architecture
Trained on 19,034 images (9,034 real + 10,000 SDXL)
Keywords: SDXL detection, AI image detection, fake image detection, deepfake detection, ResNet-50, image classification, computer vision