Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -10,70 +10,71 @@ tags:
|
|
| 10 |
pipeline_tag: video-classification
|
| 11 |
---
|
| 12 |
|
| 13 |
-
# DAViD — ViFi-CLIP
|
| 14 |
|
| 15 |
-
|
| 16 |
-
a deepfake & AI-generated video detector.
|
| 17 |
|
| 18 |
-
This repo hosts
|
| 19 |
|
| 20 |
| File | Size | Description |
|
| 21 |
|---|---|---|
|
| 22 |
| `k400_clip_complete_finetuned_30_epochs.pth` | ~1.6 GB | ViFi-CLIP (ViT-B/16) image encoder, fine-tuned on Kinetics-400 for 30 epochs |
|
|
|
|
| 23 |
|
| 24 |
-
##
|
| 25 |
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
|
| 33 |
-
|
| 34 |
-
in this repo.
|
| 35 |
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
previously hosted on Google Drive, but Drive throttles datacenter IPs and broke
|
| 40 |
-
the Space build. Serving it from the HF Hub is reliable from HF's build
|
| 41 |
-
infrastructure.
|
| 42 |
|
| 43 |
## Usage
|
| 44 |
|
| 45 |
-
Download
|
| 46 |
|
| 47 |
```python
|
| 48 |
from huggingface_hub import hf_hub_download
|
| 49 |
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
)
|
| 54 |
```
|
| 55 |
|
| 56 |
-
Load
|
| 57 |
[`aitf-its-tim3-dfk/david`](https://github.com/aitf-its-tim3-dfk/david)):
|
| 58 |
|
| 59 |
```python
|
|
|
|
| 60 |
from encoder import load_feature_extractor
|
|
|
|
| 61 |
|
| 62 |
feature_extractor = load_feature_extractor(
|
| 63 |
arch="ViT-B/16",
|
| 64 |
class_names=("real", "deepfake", "ai_gen"),
|
| 65 |
-
checkpoint_path=
|
| 66 |
).eval()
|
| 67 |
|
| 68 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 69 |
```
|
| 70 |
|
| 71 |
## Training
|
| 72 |
|
| 73 |
-
- **
|
| 74 |
-
- **
|
| 75 |
-
- **Schedule:** 30 epochs
|
| 76 |
-
- **Output dim:** 512
|
| 77 |
|
| 78 |
## Related
|
| 79 |
|
|
@@ -82,5 +83,5 @@ feature_extractor = load_feature_extractor(
|
|
| 82 |
|
| 83 |
## License
|
| 84 |
|
| 85 |
-
Set the appropriate license for these weights (currently `other`).
|
| 86 |
-
|
|
|
|
| 10 |
pipeline_tag: video-classification
|
| 11 |
---
|
| 12 |
|
| 13 |
+
# DAViD — Checkpoints (ViFi-CLIP encoder + classification head)
|
| 14 |
|
| 15 |
+
Model weights for **[DAViD](https://huggingface.co/spaces/aitf-its-tim3-dfk/David)**,
|
| 16 |
+
a deepfake & AI-generated video/image detector.
|
| 17 |
|
| 18 |
+
This repo hosts two checkpoints:
|
| 19 |
|
| 20 |
| File | Size | Description |
|
| 21 |
|---|---|---|
|
| 22 |
| `k400_clip_complete_finetuned_30_epochs.pth` | ~1.6 GB | ViFi-CLIP (ViT-B/16) image encoder, fine-tuned on Kinetics-400 for 30 epochs |
|
| 23 |
+
| `best_detector_model.pt` | ~3 MB | MLP classification head (`dense → dense1 → dense2`), trained on the DAViD dataset + CDDB |
|
| 24 |
|
| 25 |
+
## How they fit together
|
| 26 |
|
| 27 |
+
1. **Encoder** — a ViFi-CLIP (ViT-B/16) visual backbone fine-tuned on
|
| 28 |
+
Kinetics-400. Each frame (or image) is encoded into a **512-dim** embedding.
|
| 29 |
+
2. **Classification head** — a lightweight MLP that maps the (averaged) 512-dim
|
| 30 |
+
embedding to 3 classes: `real`, `deepfake`, `ai_gen`. It was trained on a mix
|
| 31 |
+
of the DAViD video dataset and **CDDB** (an image-based deepfake benchmark),
|
| 32 |
+
so it supports both video and single-image input.
|
| 33 |
|
| 34 |
+
## Why these live on the Hub
|
|
|
|
| 35 |
|
| 36 |
+
The DAViD Space downloads these at Docker build time. They were previously on
|
| 37 |
+
Google Drive, but Drive throttles datacenter IPs and broke the Space build.
|
| 38 |
+
Serving them from the HF Hub is reliable from HF's build infrastructure.
|
|
|
|
|
|
|
|
|
|
| 39 |
|
| 40 |
## Usage
|
| 41 |
|
| 42 |
+
Download (no auth needed — public repo):
|
| 43 |
|
| 44 |
```python
|
| 45 |
from huggingface_hub import hf_hub_download
|
| 46 |
|
| 47 |
+
REPO = "aitf-its-tim3-dfk/david-encoder"
|
| 48 |
+
encoder_ckpt = hf_hub_download(REPO, "k400_clip_complete_finetuned_30_epochs.pth")
|
| 49 |
+
classifier_ckpt = hf_hub_download(REPO, "best_detector_model.pt")
|
|
|
|
| 50 |
```
|
| 51 |
|
| 52 |
+
Load with the DAViD modules (from the training repo
|
| 53 |
[`aitf-its-tim3-dfk/david`](https://github.com/aitf-its-tim3-dfk/david)):
|
| 54 |
|
| 55 |
```python
|
| 56 |
+
import torch
|
| 57 |
from encoder import load_feature_extractor
|
| 58 |
+
from model import ClassificationHead
|
| 59 |
|
| 60 |
feature_extractor = load_feature_extractor(
|
| 61 |
arch="ViT-B/16",
|
| 62 |
class_names=("real", "deepfake", "ai_gen"),
|
| 63 |
+
checkpoint_path=encoder_ckpt,
|
| 64 |
).eval()
|
| 65 |
|
| 66 |
+
classifier = ClassificationHead(input_dim=512, num_classes=3)
|
| 67 |
+
classifier.load_state_dict(torch.load(classifier_ckpt, map_location="cpu", weights_only=False))
|
| 68 |
+
classifier.eval()
|
| 69 |
+
|
| 70 |
+
# feats = feature_extractor.image_encoder(frames) # (N, 512)
|
| 71 |
+
# logits = classifier(feats.mean(dim=0, keepdim=True)) # (1, 3)
|
| 72 |
```
|
| 73 |
|
| 74 |
## Training
|
| 75 |
|
| 76 |
+
- **Encoder:** CLIP ViT-B/16 (ViFi-CLIP), fine-tuned on Kinetics-400, 30 epochs, output dim 512.
|
| 77 |
+
- **Classification head:** MLP trained on DAViD video dataset + CDDB images (branch `feat-cddb`).
|
|
|
|
|
|
|
| 78 |
|
| 79 |
## Related
|
| 80 |
|
|
|
|
| 83 |
|
| 84 |
## License
|
| 85 |
|
| 86 |
+
Set the appropriate license for these weights (currently `other`). The CLIP
|
| 87 |
+
backbone, Kinetics-400, and CDDB carry their own upstream licenses/terms.
|