Imager-1-Tiny
Imager-1-Tiny is a lightweight yet powerful image classifier designed to distinguish between real photographs and AI-generated images. It is part of the IMAGER family of open-source AI detection models.
With only 25 million parameters, it offers an excellent trade-off between speed, memory consumption, and accuracy, making it ideal for resource-constrained environments.
Model Details
- Developed by: Imagers
- Model type: ResNet-50 (Convolutional Neural Network)
- Parameters: ~25 Million
- Input size: 224 x 224 pixels
- License: Apache 2.0
- Fine-tuned from: ImageNet pre-trained weights
- Optimal Threshold: 0.385 (Crucial for correct inference)
Intended Uses & Limitations
Direct Use
This model is intended for classifying images as either Real (0) or AI-Generated (1). It is optimized for speed and low memory consumption, making it ideal for edge devices, mobile applications, or backend servers with limited resources (like Railway's 512MB RAM free tier).
Out-of-Scope Use
- Medical or Legal Evidence: Do not use this model as the sole evidence in legal or medical contexts. It is a statistical tool, not a forensic authority. Always combine it with human review.
- Highly Compressed or Edited Images: The model may struggle with images that have been heavily compressed (e.g., low-quality JPEGs), heavily filtered, or contain significant post-processing artifacts not seen during training.
- Adversarial Attacks: Like all current AI detectors, this model is vulnerable to adversarial noise specifically designed to fool it.
Training Data
The model was trained on a combination of two large-scale datasets:
- Hemg/AI-Generated-vs-Real-Images-Datasets: 152,710 images.
- Rajarshi-Roy-research/Defactify_Image_Dataset: ~96,000 images (generated by DALL-E 3, Midjourney v6, SDXL, and SD3).
Label Mapping:
0= Real Image1= AI-Generated Image
⚖️ Legal & Dataset Licensing Note
While the model weights are released under the Apache 2.0 license, users must also comply with the original licenses of the training datasets. The Defactify dataset is licensed under MIT, while the Hemg dataset is intended for research purposes. Commercial use of this model should be reviewed against the original dataset terms to ensure full compliance.
Training Procedure
- Framework: PyTorch, torchvision
- Hardware: Kaggle GPU environment (NVIDIA T4 or P100)
- Epochs: Early stopping triggered at Epoch 35 (no improvement for 8 consecutive epochs).
- Total Training Time: ~6.03 hours.
- Optimization: AdamW (Learning rate:
1e-4or2e-4- update if different) - Loss Function: BCEWithLogitsLoss
- Batch Size: 32 or 64 (update if different)
- Precision: FP32 (Full precision was used to ensure numerical stability).
Evaluation Results
- Validation Accuracy: 97.03%
- Macro F1-Score: 0.9737
- F1-Score (AI Class): 0.9608
- AUC-ROC: 0.982
Confusion Matrix (Validation Set):
| Predicted Real | Predicted AI | |
|---|---|---|
| Actual Real | 11,937 | 239 |
| Actual AI | 442 | 10,288 |
The model is slightly better at detecting Real images (98.0% recall) than AI images (95.9% recall).
How to Use
Because this is a custom PyTorch model, you need to load the architecture and weights manually.
import torch
import torch.nn as nn
from torchvision import models, transforms
from PIL import Image
# 1. Define the architecture
def load_imager_tiny():
model = models.resnet50(weights=None) # We load custom weights next
# IMPORTANT: The final layer was replaced to output a single logit
model.fc = nn.Linear(model.fc.in_features, 1)
return model
# 2. Load weights
model = load_imager_tiny()
model.load_state_dict(torch.load("imager-1-tiny_best.pth", map_location="cpu"))
model.eval()
# 3. Preprocess image (Standard ImageNet normalization)
preprocess = transforms.Compose([
transforms.Resize(256),
transforms.CenterCrop(224),
transforms.ToTensor(),
transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
])
image = Image.open("your_image.jpg").convert("RGB")
input_tensor = preprocess(image).unsqueeze(0)
# 4. Inference
with torch.no_grad():
logit = model(input_tensor)
prob = torch.sigmoid(logit).item()
# 5. Apply the specific threshold (CRITICAL)
THRESHOLD = 0.385
prediction = "AI-Generated" if prob > THRESHOLD else "Real"
print(f"Probability of AI: {prob:.4f} -> Prediction: {prediction}")
- Downloads last month
- 6