Downloads · 30 days
0
mernahany666/convnext-ai-detector-finetuned
convnext-ai-detector-finetuned is a image classification model from mernahany666. Use it when you need a label for an image. It is set up for timm. The card lists the license as apache-2.0.
A convnextv2base model (via timm), fine-tuned to classify images as real vs. AI-generated, with training specifically adapted for content that has passed through social media platforms (Facebook, Instagram, TikTok).
Downloads · 30 days
0
Access
Public
Updated Jul 25, 2026
Repo size
351 MB
Likes
0
Public
Click a slice to open those files.
.pth351 MB · 100%
From the Hugging Face model README
A convnextv2_base model (via timm), fine-tuned to classify images as real vs. AI-generated, with training specifically adapted for content that has passed through social media platforms (Facebook, Instagram, TikTok).
Rather than training on clean, unmodified images, this model was fine-tuned with a domain-adaptation pipeline designed to close the gap between training data and real-world social media content:
ComplexDataLab/OpenFake's reddit config (real photos from photography subreddits, AI-generated images from AI-generation subreddits — carrying actual platform compression rather than simulated artifacts).import torch
import timm
from huggingface_hub import hf_hub_download
REPO_ID = "your-username/convnext-ai-detector-finetuned" # <-- replace with your actual repo id
WEIGHTS_FILENAME = "best_convnext_v2_model.pth"
weights_path = hf_hub_download(repo_id=REPO_ID, filename=WEIGHTS_FILENAME)
model = timm.create_model("convnextv2_base", pretrained=False, num_classes=2)
state_dict = torch.load(weights_path, map_location="cpu")
model.load_state_dict(state_dict)
model.eval()
Use the same resize/crop/normalize pipeline as training's validation transform:
from torchvision import transforms
_convnext_mean = (0.485, 0.456, 0.406)
_convnext_std = (0.229, 0.224, 0.225)
infer_transform = transforms.Compose([
transforms.Resize(288, interpolation=transforms.InterpolationMode.LANCZOS),
transforms.CenterCrop(256),
transforms.ToTensor(),
transforms.Normalize(_convnext_mean, _convnext_std),
])
from PIL import Image
import torch.nn.functional as F
image = Image.open("your_image.jpg").convert("RGB")
tensor = infer_transform(image).unsqueeze(0)
with torch.no_grad():
logits = model(tensor)
probs = F.softmax(logits, dim=1)[0]
print(probs) # see "Class order" below for how to read this
⚠️ Fill this in before publishing — this model was trained with torchvision.datasets.ImageFolder, which assigns class indices alphabetically by folder name. The training notebook prints this at runtime as Classes found: [...].
Replace the placeholders below with your actual training output:
| Index | Class |
|---|---|
| 0 | <class_0_name> (e.g. ai) |
| 1 | <class_1_name> (e.g. real) |
Getting this backwards will silently invert every prediction downstream (this has bitten this exact model before — double check it).
convnextv2_base (ImageNet-pretrained, fully fine-tuned)3e-5, cosine annealing schedulereddit-sourced portion of training data is licensed CC-BY-NC-4.0 for its proprietary-generator subsets — check licensing before commercial use of this model.Binary classification of images (or video frames) as real vs. AI-generated, particularly for content sourced from or resembling social media platforms. Not intended as a sole arbiter of authenticity — use as one signal within a broader verification pipeline (e.g. alongside a dedicated deepfake/face-manipulation detector).