forked from richzhang/colorization-pytorch
-
Notifications
You must be signed in to change notification settings - Fork 1
/
make_ilsvrc_dataset.py
37 lines (31 loc) · 1.56 KB
/
make_ilsvrc_dataset.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
import os
import sys
from util import util
import numpy as np
import argparse
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter)
parser.add_argument('--in_path', type=str, default='/data/big/dataset/ILSVRC2012')
parser.add_argument('--out_path', type=str, default='./dataset/ilsvrc2012/')
opt = parser.parse_args()
orig_path = opt.in_path
print('Copying ILSVRC from...[%s]'%orig_path)
# Copy over whole training set
trn_path = os.path.join(opt.out_path,'train')
util.mkdirs(opt.out_path)
os.symlink(os.path.join(opt.in_path,'train'),trn_path)
print('Making training set in...[%s]'%trn_path)
# Copy over subset of ILSVRC12 val set for colorization val set
val_path = os.path.join(opt.out_path,'val/imgs')
util.mkdirs(val_path)
print('Making validation set in...[%s]'%val_path)
for val_ind in range(1000):
os.system('ln -s %s/val/ILSVRC2012_val_%08d.JPEG %s/ILSVRC2012_val_%08d.JPEG'%(orig_path,val_ind+1,val_path,val_ind+1))
# os.system('cp %s/val/ILSVRC2012_val_%08d.JPEG %s/ILSVRC2012_val_%08d.JPEG'%(orig_path,val_ind+1,val_path,val_ind+1))
# Copy over subset of ILSVRC12 val set for colorization test set
test_path = os.path.join(opt.out_path,'test/imgs')
util.mkdirs(test_path)
val_inds = np.load('./resources/ilsvrclin12_val_inds.npy')
print('Making test set in...[%s]'%test_path)
for val_ind in val_inds:
os.system('ln -s %s/val/ILSVRC2012_val_%08d.JPEG %s/ILSVRC2012_val_%08d.JPEG'%(orig_path,val_ind+1,test_path,val_ind+1))
# os.system('cp %s/val/ILSVRC2012_val_%08d.JPEG %s/ILSVRC2012_val_%08d.JPEG'%(orig_path,val_ind+1,test_path,val_ind+1))