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
fix: resolve old checkpoint path relative to repo root
Browse filesPreviously used a relative path that would fail depending on CWD.
Now resolved via __file__ to always point to the correct pretrained_weights/ directory.
- test_app/app.py +6 -1
test_app/app.py
CHANGED
|
@@ -57,8 +57,13 @@ def _load_old_model():
|
|
| 57 |
device = old_cfg["device"]
|
| 58 |
if not torch.cuda.is_available():
|
| 59 |
device = "cpu"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
model = OldViTClassifier(old_cfg, device=device)
|
| 61 |
-
ckpt = torch.load(
|
| 62 |
model.load_state_dict(ckpt["model"])
|
| 63 |
return model.to(device).eval()
|
| 64 |
|
|
|
|
| 57 |
device = old_cfg["device"]
|
| 58 |
if not torch.cuda.is_available():
|
| 59 |
device = "cpu"
|
| 60 |
+
# Resolve checkpoint path relative to repo root (one level up from test_app/)
|
| 61 |
+
ckpt_rel = old_cfg["checkpoint_path"]
|
| 62 |
+
ckpt_path = os.path.join(os.path.dirname(os.path.dirname(__file__)), ckpt_rel)
|
| 63 |
+
if not os.path.exists(ckpt_path):
|
| 64 |
+
raise FileNotFoundError(f"Checkpoint not found: {ckpt_path}")
|
| 65 |
model = OldViTClassifier(old_cfg, device=device)
|
| 66 |
+
ckpt = torch.load(ckpt_path, map_location=device, weights_only=False)
|
| 67 |
model.load_state_dict(ckpt["model"])
|
| 68 |
return model.to(device).eval()
|
| 69 |
|