-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathStep0_download_BDDVdata.py
executable file
·68 lines (57 loc) · 2.14 KB
/
Step0_download_BDDVdata.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
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
#|**********************************************************************;
# Project : Explainable Deep Driving
#
# File name : Step0_download_BDDVdata.py
#
# Author : Jinkyu Kim
#
# Date created : 20181201
#
# Purpose : Download .mov files of BDD-V dataset
#
# Revision History :
#
# Date Author Ref Revision
# 20181201 jinkyu 1 initiated
#
# Remark
#|**********************************************************************;
from sys import platform
from tqdm import tqdm
import os
import wget
from src.utils import *
# Main function
#----------------------------------------------------------------------
if __name__ == "__main__":
if platform == 'darwin':
config = dict2(**{
"annotations": './data/Sample.csv', # contains (video url, start, end, action, justification)
"vid_path": './data/Videos/videos/'})
else:
raise NotImplementedError
if not os.path.exists(config.vid_path): os.makedirs(config.vid_path)
with open(config.annotations) as f_obj:
examples = csv_dict_reader(f_obj)
'''
Keys:
1. Input.Video
2. Answer.1start
3. Answer.1end
4. Answer.1action
5. Answer.1justification
'''
non_exist_vidNames = []
for item in tqdm(examples):
vidName = item['Input.Video'].split("/")[-1][:-4]
if len(vidName)==0: continue
print(bcolors.HEADER + "Video: {}".format(vidName) + bcolors.ENDC)
#--------------------------------------------------
# Read video clips
#--------------------------------------------------
str2read = '%s%s.mov'%(config.vid_path, vidName) # original resolution: 720x1280
if not os.path.exists(str2read):
print(bcolors.BOLD + "Download video clips: {}".format(vidName) + bcolors.ENDC)
wget.download(item['Input.Video'], out=str2read)
else:
print(bcolors.BOLD + "Already downloaded: {}".format(vidName) + bcolors.ENDC)