bsgcasa / vit-real-vs-ai-detector

huggingface.co
Total runs: 0
24-hour runs: 0
7-day runs: 0
30-day runs: 0
Model's Last Updated: September 04 2026
image-classification

Introduction of vit-real-vs-ai-detector

Model Details of vit-real-vs-ai-detector

ViT Real vs. AI-Generated Image Classifier (CIFAKE Fine-tune)

A vit_base_patch16_224 model fine-tuned on the CIFAKE dataset to classify images as REAL or FAKE (AI-generated).

Model Details
  • Base model: vit_base_patch16_224 (ImageNet pretrained, via timm )
  • Fine-tuning data: CIFAKE (real CIFAR-10 images vs. GAN-generated synthetic images)
  • Input size: 224×224 (upscaled from the dataset's native 32×32)
  • Classes: REAL (0), FAKE (1)
  • Training: 5 epochs, AdamW, cosine LR schedule, 1 epoch of backbone freezing (head-only warmup)
Reported Metrics (CIFAKE test set)
Metric Value
Test Accuracy 99.30%
Test AUC 0.9996
Precision (REAL / FAKE) 0.9936 / 0.9925
Recall (REAL / FAKE) 0.9925 / 0.9936

These numbers are correct and reproducible — but they describe performance on CIFAKE's own held-out test distribution only. Read the limitation below before using this model on any other kind of image.

⚠️ Known Limitation: This Model Does Not Generalize to Real-World, High-Resolution Images

This is not a minor caveat — it's a fundamental scope limitation that anyone using this model needs to understand.

What the model actually learned

CIFAKE's "REAL" class consists of CIFAR-10 photos, which are natively 32×32 pixels , upscaled to 224×224 for ViT input. Its "FAKE" class consists of one specific (older) GAN's outputs, generated at a similarly low native resolution and likewise upscaled.

As a result, the model did not learn general "does this image look AI-generated" cues (e.g. unnatural textures, inconsistent lighting/shadows, anatomical errors, diffusion/GAN fingerprints). Instead, it learned to detect the blur, interpolation, and compression signature of a 32×32 image stretched to 224×224 , versus the specific artifact signature of that one GAN at the same tiny native resolution.

Why this matters in practice

Any modern, high-resolution photo — a phone photo, a Wikipedia image, a stock photo — has a sharpness and compression profile that looks nothing like CIFAKE's upscaled-32×32 "REAL" class. The model has no learned category for "real photo, but sharp and high-res," so it defaults to predicting FAKE , regardless of the image's actual origin.

Confirmed empirically: high-resolution real photographs (e.g. a standard press photo of a named public figure) were consistently misclassified as FAKE. When the same images were first downscaled to 32×32 and upscaled back to 224×224 (artificially reproducing CIFAKE's REAL image distribution), predictions correctly flipped to REAL. This confirms the model is substantially keying on resolution/compression artifacts , not genuine evidence of AI generation.

What this means for use
Use case Reliable?
Classifying images that are natively low-resolution (≈32×32) or have gone through similar upscaling, matching CIFAKE's distribution Yes — this is what the reported 99.3% reflects
Classifying arbitrary high-resolution real-world photos No — biased toward predicting FAKE
Detecting output from modern generators (Midjourney, DALL·E, Stable Diffusion/SDXL, Flux, etc.) Not validated — CIFAKE's FAKE images come from one older, lower-resolution GAN; artifacts from modern diffusion models were never seen during training
General-purpose "is this image AI-generated" detection on the internet/social media Not recommended as-is
Recommended paths for a general-purpose detector

If you need a detector that works on arbitrary real-world images, this checkpoint should be treated as a baseline/proof-of-concept, not a deployable classifier. Effective next steps include:

  1. Remove the resolution confound in training: apply matched downscale/upscale or JPEG recompression augmentation to both classes, so the model can't shortcut on resolution and must learn from actual generation artifacts.
  2. Train on modern, high-resolution data: mix in datasets covering current-generation models (e.g. GenImage) alongside high-resolution real photo sources, rather than relying on CIFAKE alone.
  3. Evaluate out-of-distribution before trusting the model: always test on a held-out set of high-res real photos and multiple modern generators before drawing conclusions about generalization — in-distribution test accuracy (like the 99.3% above) does not imply real-world reliability.
Intended Use

This model is best suited for:

  • Educational/benchmarking purposes on the CIFAKE dataset itself
  • A starting checkpoint for further fine-tuning toward a more general detector
  • Demonstrating ViT fine-tuning workflows for binary image classification

It is not recommended for production content-moderation, journalism verification, or any deployment where accuracy on arbitrary real-world images is required.

How to Use
import torch
import timm
from torchvision import transforms
from PIL import Image

model = timm.create_model("vit_base_patch16_224", pretrained=False, num_classes=2)
state_dict = torch.load("final_model_state_dict.pt", map_location="cpu")
model.load_state_dict(state_dict)
model.eval()

transform = transforms.Compose([
    transforms.Resize((224, 224)),
    transforms.ToTensor(),
    transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
])

img = Image.open("your_image.jpg").convert("RGB")
x = transform(img).unsqueeze(0)

with torch.no_grad():
    probs = torch.softmax(model(x), dim=1)[0]

print(f"REAL: {probs[0]:.2%} | FAKE: {probs[1]:.2%}")

Note: as explained above, expect unreliable results on high-resolution, real-world images unless you retrain with the fixes described in the Limitations section.

Training Data

CIFAKE: Real and AI-Generated Synthetic Images — 60,000 real (CIFAR-10) and 60,000 AI-generated (GAN) images, 32×32 resolution.

License

MIT (adjust to match your intended distribution terms).

Runs of bsgcasa vit-real-vs-ai-detector on huggingface.co

0
Total runs
0
24-hour runs
0
3-day runs
0
7-day runs
0
30-day runs

More Information About vit-real-vs-ai-detector huggingface.co Model

More vit-real-vs-ai-detector license Visit here:

https://choosealicense.com/licenses/mit

vit-real-vs-ai-detector huggingface.co

vit-real-vs-ai-detector huggingface.co is an AI model on huggingface.co that provides vit-real-vs-ai-detector's model effect (), which can be used instantly with this bsgcasa vit-real-vs-ai-detector model. huggingface.co supports a free trial of the vit-real-vs-ai-detector model, and also provides paid use of the vit-real-vs-ai-detector. Support call vit-real-vs-ai-detector model through api, including Node.js, Python, http.

vit-real-vs-ai-detector huggingface.co Url

https://huggingface.co/bsgcasa/vit-real-vs-ai-detector

bsgcasa vit-real-vs-ai-detector online free

vit-real-vs-ai-detector huggingface.co is an online trial and call api platform, which integrates vit-real-vs-ai-detector's modeling effects, including api services, and provides a free online trial of vit-real-vs-ai-detector, you can try vit-real-vs-ai-detector online for free by clicking the link below.

bsgcasa vit-real-vs-ai-detector online free url in huggingface.co:

https://huggingface.co/bsgcasa/vit-real-vs-ai-detector

vit-real-vs-ai-detector install

vit-real-vs-ai-detector is an open source model from GitHub that offers a free installation service, and any user can find vit-real-vs-ai-detector on GitHub to install. At the same time, huggingface.co provides the effect of vit-real-vs-ai-detector install, users can directly use vit-real-vs-ai-detector installed effect in huggingface.co for debugging and trial. It also supports api for free installation.

vit-real-vs-ai-detector install url in huggingface.co:

https://huggingface.co/bsgcasa/vit-real-vs-ai-detector

Url of vit-real-vs-ai-detector

vit-real-vs-ai-detector huggingface.co Url

Provider of vit-real-vs-ai-detector huggingface.co

bsgcasa
ORGANIZATIONS

Other API from bsgcasa