-
-
Notifications
You must be signed in to change notification settings - Fork 73
/
prepare_cvusa.py
60 lines (47 loc) · 1.99 KB
/
prepare_cvusa.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
import os
from shutil import copyfile
download_path = 'data/cvpr2017_cvusa/'
train_split = download_path + 'splits/train-19zl.csv'
train_save_path = download_path + 'train/'
if not os.path.isdir(train_save_path):
os.mkdir(train_save_path)
os.mkdir(train_save_path + 'street')
os.mkdir(train_save_path + 'satellite')
with open(train_split) as fp:
line = fp.readline()
while line:
filename = line.split(',')
#print(filename[0])
src_path = download_path + '/' + filename[0]
dst_path = train_save_path + '/satellite/' + os.path.basename(filename[0][:-4])
if not os.path.isdir(dst_path):
os.mkdir(dst_path)
copyfile(src_path, dst_path + '/' + os.path.basename(filename[0]))
src_path = download_path + '/' + filename[1]
dst_path = train_save_path + '/street/' + os.path.basename(filename[1][:-4])
if not os.path.isdir(dst_path):
os.mkdir(dst_path)
copyfile(src_path, dst_path + '/' + os.path.basename(filename[1]))
line = fp.readline()
val_split = download_path + 'splits/val-19zl.csv'
val_save_path = download_path + 'val/'
if not os.path.isdir(val_save_path):
os.mkdir(val_save_path)
os.mkdir(val_save_path + 'street')
os.mkdir(val_save_path + 'satellite')
with open(val_split) as fp:
line = fp.readline()
while line:
filename = line.split(',')
#print(filename[0])
src_path = download_path + '/' + filename[0]
dst_path = val_save_path + '/satellite/' + os.path.basename(filename[0][:-4])
if not os.path.isdir(dst_path):
os.mkdir(dst_path)
copyfile(src_path, dst_path + '/' + os.path.basename(filename[0]))
src_path = download_path + '/' + filename[1]
dst_path = val_save_path + '/street/' + os.path.basename(filename[1][:-4])
if not os.path.isdir(dst_path):
os.mkdir(dst_path)
copyfile(src_path, dst_path + '/' + os.path.basename(filename[1]))
line = fp.readline()