-
Notifications
You must be signed in to change notification settings - Fork 18
/
examples.sh
92 lines (78 loc) · 3.11 KB
/
examples.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
cd src
: '
Lets say you have 3 videos: a.mp4, b.mp4 & c.mp4 and you want to check their authenticity. In order to do so, place them in the sample_videos/ folder.
Now, you have 3 options: either use models trained on FFPP, DFDC or CelebDF dataset.
For each dataset, we have 4 models: EfficientNetV2 (V2), EfficientNetV2 ST (V2 ST), Vision Transformer (ViT) & Vision Transformer ST (VIT ST).
Consider, you decided to use the models trained on DFDC dataset. So in order to download the models and setup the files, run the setup.sh file by executing
./setup.sh -m dfdc
The -m flag with dfdc will download the models trained on DFDC dataset. Once the execution of setup.sh is finished, you can start with running the main code.
In the code, the 3 videos which are placed in the sample_videos folder are first arranged alphabetically and indexed as:
a.mp4 0
b.mp4 1
c.mp4 2
These indexes 0,1,2 are used as --video_id argument while running the main code. See the example below:
'
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/ \
--dataset dfdc \
--model TimmV2 TimmV2ST ViT ViTST \
--model_dir ../models/ \
--video_id 0 1 2 \
--annotate True
: '
In the above command, all the 3 videos i.e a.mp4, b.mp4 and c.mp4 are chosen via the --video_id argument. The --model argument specifies a list of
models that have to be ensembled in order to make predictions. The --data_dir argements points to the path where the 3 videos that have to be analysed are
saved. After running this code, the annotated video is stored in the src/output/ folder and the predictions are stored in src/output/predictions.csv
'
# Some other examples:
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/ffpp/fake/ \
--dataset ffpp \
--model ViT ViTST \
--model_dir ../models/ \
--video_id 1 2 \
--annotate True
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/celeb/fake/ \
--dataset celeb \
--model TimmV2 TimmV2ST ViT ViTST \
--model_dir ../models/ \
--video_id 3 \
--annotate True
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/dfdc/real/ \
--dataset dfdc \
--model TimmV2ST ViTST \
--model_dir ../models/ \
--video_id 0 1 \
--annotate True
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/ffpp/fake/ \
--dataset dfdc \
--model TimmV2 TimmV2ST ViT ViTST \
--model_dir ../models/ \
--video_id 2 3 \
--annotate True
python3 spot_deepfakes.py \
--media_type video \
--data_dir ../sample_videos/celeb/real/ \
--dataset ffpp \
--model ViT ViTST \
--model_dir ../models/ \
--video_id 1 \
--annotate True
: '
If you want to test authenticity of an image, then place the image in the sample_images folder. And run the below command. The predictions will be stored in src/output/img_predictions.json file.
'
python3 spot_deepfakes.py \
--media_type image \
--data_dir ../sample_images/ \
--dataset ffpp \
--model TimmV2 TimmV2ST ViT ViTST \
--model_dir ../models/ \
--device 2