Instructions to use buildborderless/CommunityForensics-DeepfakeDet-ViT with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Transformers
How to use buildborderless/CommunityForensics-DeepfakeDet-ViT with Transformers:
# Use a pipeline as a high-level helper from transformers import pipeline pipe = pipeline("image-classification", model="buildborderless/CommunityForensics-DeepfakeDet-ViT") pipe("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/hub/parrots.png")# Load model directly from transformers import AutoImageProcessor, AutoModelForImageClassification processor = AutoImageProcessor.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT") model = AutoModelForImageClassification.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT", device_map="auto") - timm
How to use buildborderless/CommunityForensics-DeepfakeDet-ViT with timm:
import timm model = timm.create_model("hf_hub:buildborderless/CommunityForensics-DeepfakeDet-ViT", pretrained=True) - Inference
- Notebooks
- Google Colab
- Kaggle
AGENTS.md β CommunityForensics-DeepfakeDet-ViT
What this repo is
Hugging Face model repo for buildborderless/CommunityForensics-DeepfakeDet-ViT β a ViT-Small classifier for deepfake image detection. Trained on 2.7M samples across 4,803 generators. This is a model distribution repo (no app, no build, no tests).
Key files
model.safetensorsβ HF-format weights (Git LFS β ensuregit lfs pullafter clone)config.jsonβViTForImageClassificationconfig (384Γ384, 6 heads, num_labels=1, sigmoid output: real/fake)preprocessor_config.jsonβ CLIP-style normalization, resize to shortest_edge=440, center-crop to 384modeling_vit_classifier.pyβ DEPRECATED (moved toscripts/). Use standard HF path below.pretrained_weights/β original.ptcheckpoints from training (also LFS)onnx/β 5 pre-exported ONNX variants (15MBβ84MB) for CPU/GPU deployment. See README for variant guide.
Usage
The model is hosted on Hugging Face. The standard way to load it is via transformers:
from transformers import ViTForImageClassification, ViTImageProcessor
model = ViTForImageClassification.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT")
processor = ViTImageProcessor.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT")
The custom wrapper (modeling_vit_classifier.py) uses timm.create_model with a sigmoid output and pretrained_weights/model_v11_ViT_384_base_ckpt.pt. This is for standalone (non-HF-pipeline) inference requiring both timm and transformers.
Dependencies
transformers >= 5.4.0(required β older versions lackshortest_edgeresize and will squash images)timm(for the deprecated ViTClassifier wrapper only)torch,torchvision,Pillowonnxruntime >= 1.27(for ONNX models)
Scripts (in scripts/)
Data processing utilities for the eval dataset β not needed for inference:
convert_to_pytorch.pyβ convert timm checkpoints to HuggingFace formatresample_evalset.pyβ face-detection-based dataset filteringrestructure.pyβ reorganize real/generated image directoriesquick_analysis.pyβ dataset statistics report
Git LFS
All weight files (.safetensors, .pt, .ckpt, .onnx) are stored via Git LFS. Always run git lfs pull after cloning or the model files will be pointer stubs. The full ONNX model alone is 138MB β pull selectively with git lfs pull --include="onnx/model_int8.onnx" if you only need one variant.
Remote
This repo is pushed to https://huggingface.co/buildborderless/CommunityForensics-DeepfakeDet-ViT, not GitHub. Standard gh CLI commands will not work.