Image Classification
Transformers
ONNX
Safetensors
timm
vit
detection
deepfake
forensics
deepfake_detection
community
opensight
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")# pip install -U transformers accelerate # 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
Commit History
-
fix: address reviewer feedback — qualify claims, fix AGENTS.md, add quantization caveat
- CHANGELOG: remove '<0.004% across all' claim, explain portrait deviation - AGENTS.md: num_labels=1 sigmoid output, updated ONNX sizes - README: soften INT8 claims, add quantization accuracy note - Low severity: trailing newline, expanded .gitignoree373e82 -
fix: use num_labels=1 instead of num_classes=1
num_classes=1 maps to num_labels=2 internally in ViTConfig, creating [2,384] classifier that mismatches the safetensors. num_labels=1 produces [1,384] — correct for single-class sigmoid.76aa01e -
docs: restore OpenSight community validation and preview sections
12fe8c7 -
docs: mention AGENTS.md for LLM tools, add benchmark Space section
0c4843a -
docs: final README overhaul + CHANGELOG for July 2026 fix
311da96 -
fix: remove id2label/label2id — not meaningful for num_classes=1 sigmoid output
900dbcc -
chore: rename onnx_v1.1→onnx_legacy; update LICENSE
- onnx_v1.1/ → onnx_legacy/: old (incorrect) ONNX exports archived - LICENSE: add 2025 + 2026 copyright lines for Han Yoon, Borderless / Ethix R&D - Original copyright (c) 2025 Jeongsoo Park preserved as-isa4dbb37 -
docs: remove test_app references, update ONNX count to 5 variants
04f074e -
chore: exclude test_app from repo (deploy as separate HF Space)
5d56548 -
chore: require transformers >= 5.4.0 for shortest_edge resize support
The preprocessor_config uses shortest_edge: 440 which requires transformers >= 5.4.0. Older versions will crash with a ValueError demanding height/width keys instead.3393101 -
feat: update test_app for corrected ONNX v1.1, single-class output
- ONNX directory: new 5 variants (84 MB FP32 down to 16 MB Q4) - Test app: handle num_classes=1 sigmoid output for ONNX - Benchmark tab: updated for single-class ONNX output - Added quantize_config.json for ONNX export metadata6f9c8ad -
feat: re-export ONNX from corrected ViT-Small weights
5 variants exported via optimum-cli + onnxruntime quantization: - model.onnx (84 MB): FP32 base, matches PyTorch exactly - model_int8.onnx (22 MB): dynamic INT8, best CPU speed - model_uint8.onnx (22 MB): dynamic UINT8 - model_quantized.onnx (22 MB): alias of INT8 - model_q4.onnx (16 MB): 4-bit MatMul, smallest with good accuracy Legacy ONNX variants archived in onnx_v1.1/. FP16 and BNB4 skipped due to library API incompatibilities.e152b83 -
chore: archive legacy weights, rename ONNX to v1.1
- model_legacy.safetensors: archived old (incorrect) weights - model_fixed.safetensors: explicit copy of current corrected weights - onnx/ → onnx_v1.1/: ready for fresh re-export804dea9 -
test: add 8 evaluation images (real, fake, and adversarial)
881824b -
docs: update README for num_classes=1 sigmoid output, correct verification
The model uses single-class output with sigmoid, not 2-class softmax. Also adds intermediate_size=1536 to the verification check.05df049 -
fix: regenerate model.safetensors from correct .pt checkpoint
The old safetensors was converted from different weights (intermediate_size=3072, num_classes=2 classifier, different backbone weights) instead of the correct trained checkpoint (intermediate_size=1536, num_classes=1, ViT-Small 6 heads). Changes: - model.safetensors: regenerated from pretrained_weights/model_v11_ViT_384_base_ckpt.pt - config.json: num_classes=2→1, intermediate_size=3072→1536, correct for ViT-Small - preprocessor_config.json: size changed to shortest_edge=440 (no more squashing) - test_app: handle num_classes=1 with sigmoid outputb0b641e -
fix: resolve old checkpoint path relative to repo root
Previously used a relative path that would fail depending on CWD. Now resolved via __file__ to always point to the correct pretrained_weights/ directory.7ec67b8
-
feat: add Old vs New comparison tab
Compares the deprecated timm ViTClassifier against the fixed HF ViTForImageClassification pipeline. Same weights, different loading paths — proves the fix is transparent and correct.4d30312 -
chore: stash UI improvements before test images
228935d -
docs: update AGENTS.md — ONNX directory, test app, corrected config specs
502665e -
feat: test app v2 — compare tab, benchmark tab, help tab
- Compare: side-by-side PyTorch vs ONNX with timing - Benchmark: run all 8 ONNX variants against test_app/images/ directory - Help: usage guide and variant selection advice - Auto-detects GPU/CPU for both frameworksccffb9c -
docs: overhaul README — fix notice, ONNX variant guide, test app, deprecate old ONNX repo
Add LICENSE (MIT — dual copyright, original + HF integration)4c85d93 -
feat: add ONNX quantized variants (8 models, 21MB–138MB)
- full FP32 (138 MB): best accuracy, no quantization loss - fp16 (69 MB): half precision, minimal accuracy loss - int8 / uint8 / quantized (36 MB): balanced speed/accuracy, best for CPU - q4 (24 MB): aggressive 4-bit quantization - bnb4 (22 MB): bitsandbytes 4-bit - q4f16 (21 MB): smallest, 4-bit with fp16 computeeebc18e -
chore: move custom wrapper to scripts/, mark as deprecated
Standard inference path is now ViTForImageClassification.from_pretrained(). The timm-based wrapper is kept for backwards compatibility only.ce27b42 -
fix: correct ViT-Small config — num_classes(1→2), num_attention_heads(12→6), preprocessor(resize 440→384 crop)
- num_classes: 1→2 (classifier weight shape is [2,384], was silently crashing) - num_attention_heads: 12→6 (weights were being sliced into wrong head dims) - preprocessor: size changed to {height:440,width:440} with do_center_crop - added id2label/label2id, input_size for HF inference widget - removed redundant fields (num_heads, num_layers, mlp_ratio, encoder_stride)9c142fd
-
Update README.md
Verified signaturea54ed6c
-
Update preprocessor_config.json
Verified signature891d991 -
Update preprocessor_config.json
Verified signature312bc2a
-
Update preprocessor_config.json
Verified signaturee9dadf1 -
Update preprocessor_config.json
Verified signaturec1ac6fa -
Update preprocessor_config.json
Verified signature9bd8027 -
Update README.md
Verified signature22b51fb
-
Add project page and link to paper (#2)
Verified signature- Add project page and link to paper (6b7e35df8f39e17cee95d303b404cf2a6ac203de) Co-authored-by: Niels Rogge <nielsr@users.noreply.huggingface.co>761adfb
-
Update preprocessor_config.json
Verified signature7c67b0d -
Rename preprocessor.json to preprocessor_config.json
Verified signature85addc9 -
chore: final config (hopefully)
Verified signatureba655de -
Update README.md
Verified signature9309ac4 -
Update README.md
Verified signaturee888dd5 -
Upload ViTForImageClassification (#1)
Verified signature- Upload ViTForImageClassification (8afc0ec822088fa52ffd1bd502b66f11317b5442)3878584
-
Create 03-analysis.txt
Verified signatureb29435f -
Create 02-restructure.txt
Verified signatured9de785 -
Create quick_analysis.py
Verified signature83314dd -
chore: restructure new evalset
Verified signature33341d9 -
add: eval dataset resampling round 1
Verified signature52f46c9 -
Create logs/.gitkeep
Verified signature6ccccb2 -
chore: resample-prep
Verified signatureOpenCV's Haar Cascades for face detection + re-sampling roughly 20% of original evalsete174112 -
Create scripts/convert_to_pytorch.py
Verified signature4c6c42a -
Update README.md
Verified signature73f5f27 -
Update config.json
Verified signaturec510470 -
Update README.md
Verified signaturee68f079