-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathfilter_videos.py
27 lines (26 loc) · 975 Bytes
/
filter_videos.py
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
import json
import os
import shutil
Dir='' ## location of DFDC dataset folder
Dir_Fake= '' ## location of Folder where you want fake videos
Dir_Real= '' ## location of Folder where you want real videos
alls1=os.listdir(Dir)
for a in alls1:
alls2=os.listdir(Dir+a)
alls2=[v for v in alls2 if '.json' in v]
for i in alls2:
with open(Dir+a+'/'+i) as f:
print(Dir+a+'/'+i)
data = json.load(f)
for i in data:
try:
if data[i]['label'] == 'FAKE':
print(data[i])
shutil.copy(Dir+a+'/'+i,Dir_Fake+i)
original=data[i]['original']
shutil.copy(Dir+a+'/'+original,Dir_Real+original)
elif data[i]['label'] == 'REAL':
shutil.copy(Dir+a+'/'+i,Dir_Real+i)
print(data[i])
except:
print('missed')