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")# 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
chore: require transformers >= 5.4.0 for shortest_edge resize support
Browse filesThe preprocessor_config uses shortest_edge: 440 which requires
transformers >= 5.4.0. Older versions will crash with a ValueError
demanding height/width keys instead.
- AGENTS.md +3 -2
- README.md +5 -1
- config.json +1 -1
AGENTS.md
CHANGED
|
@@ -23,9 +23,10 @@ processor = ViTImageProcessor.from_pretrained("buildborderless/CommunityForensic
|
|
| 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
|
| 27 |
-
- `timm` (for the
|
| 28 |
- `torch`, `torchvision`, `Pillow`
|
|
|
|
| 29 |
|
| 30 |
## Scripts (in `scripts/`)
|
| 31 |
Data processing utilities for the eval dataset — not needed for inference:
|
|
|
|
| 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 >= 5.4.0` (required — older versions lack `shortest_edge` resize and will squash images)
|
| 27 |
+
- `timm` (for the deprecated ViTClassifier wrapper only)
|
| 28 |
- `torch`, `torchvision`, `Pillow`
|
| 29 |
+
- `onnxruntime >= 1.27` (for ONNX models)
|
| 30 |
|
| 31 |
## Scripts (in `scripts/`)
|
| 32 |
Data processing utilities for the eval dataset — not needed for inference:
|
README.md
CHANGED
|
@@ -66,7 +66,11 @@ The separate [`buildborderless/CommunityForensics-DeepfakeDet-ViT-ONNX`](https:/
|
|
| 66 |
|
| 67 |
---
|
| 68 |
|
| 69 |
-
##
|
|
|
|
|
|
|
|
|
|
|
|
|
| 70 |
|
| 71 |
```python
|
| 72 |
from transformers import ViTForImageClassification, ViTImageProcessor
|
|
|
|
| 66 |
|
| 67 |
---
|
| 68 |
|
| 69 |
+
## Dependencies
|
| 70 |
+
|
| 71 |
+
- `transformers >= 5.4.0` (required for correct image resize — versions < 5.4.0 will squash non-square images)
|
| 72 |
+
- `torch`, `torchvision`, `Pillow`
|
| 73 |
+
- `onnxruntime >= 1.27` (for ONNX models)
|
| 74 |
|
| 75 |
```python
|
| 76 |
from transformers import ViTForImageClassification, ViTImageProcessor
|
config.json
CHANGED
|
@@ -25,5 +25,5 @@
|
|
| 25 |
"patch_size": 16,
|
| 26 |
"qkv_bias": true,
|
| 27 |
"torch_dtype": "float32",
|
| 28 |
-
"transformers_version": "4.
|
| 29 |
}
|
|
|
|
| 25 |
"patch_size": 16,
|
| 26 |
"qkv_bias": true,
|
| 27 |
"torch_dtype": "float32",
|
| 28 |
+
"transformers_version": "5.4.0"
|
| 29 |
}
|