ethix commited on
Commit
502665e
·
1 Parent(s): ccffb9c

docs: update AGENTS.md — ONNX directory, test app, corrected config specs

Browse files
Files changed (1) hide show
  1. AGENTS.md +41 -0
AGENTS.md ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # AGENTS.md — CommunityForensics-DeepfakeDet-ViT
2
+
3
+ ## What this repo is
4
+ 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).
5
+
6
+ ## Key files
7
+ - **`model.safetensors`** — HF-format weights (Git LFS — ensure `git lfs pull` after clone)
8
+ - **`config.json`** — `ViTForImageClassification` config (384×384, 6 heads, 2 output classes: real/fake)
9
+ - **`preprocessor_config.json`** — CLIP-style normalization, resize to 440, center-crop to 384
10
+ - **`modeling_vit_classifier.py`** — **DEPRECATED** (moved to `scripts/`). Use standard HF path below.
11
+ - **`pretrained_weights/`** — original `.pt` checkpoints from training (also LFS)
12
+ - **`onnx/`** — 8 pre-exported ONNX variants (21MB–138MB) for CPU/GPU deployment. See README for variant guide.
13
+ - **`test_app/`** — local Gradio app for testing PyTorch vs ONNX, benchmarking, and comparison
14
+
15
+ ## Usage
16
+ The model is hosted on Hugging Face. The standard way to load it is via `transformers`:
17
+ ```python
18
+ from transformers import ViTForImageClassification, ViTImageProcessor
19
+ model = ViTForImageClassification.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT")
20
+ processor = ViTImageProcessor.from_pretrained("buildborderless/CommunityForensics-DeepfakeDet-ViT")
21
+ ```
22
+
23
+ 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`.
24
+
25
+ ## Dependencies
26
+ - `transformers` >= 4.50.0
27
+ - `timm` (for the custom ViTClassifier wrapper only)
28
+ - `torch`, `torchvision`, `Pillow`
29
+
30
+ ## Scripts (in `scripts/`)
31
+ Data processing utilities for the eval dataset — not needed for inference:
32
+ - `convert_to_pytorch.py` — convert timm checkpoints to HuggingFace format
33
+ - `resample_evalset.py` — face-detection-based dataset filtering
34
+ - `restructure.py` — reorganize real/generated image directories
35
+ - `quick_analysis.py` — dataset statistics report
36
+
37
+ ## Git LFS
38
+ 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.
39
+
40
+ ## Remote
41
+ This repo is pushed to `https://huggingface.co/buildborderless/CommunityForensics-DeepfakeDet-ViT`, not GitHub. Standard `gh` CLI commands will not work.