-
Notifications
You must be signed in to change notification settings - Fork 1
/
setup.py
40 lines (32 loc) · 1.08 KB
/
setup.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
import os
import sys
import urllib
import zipfile
import re
import argparse
if sys.version_info >= (3, 0):
import urllib.request
URLLIB = urllib
if sys.version_info >= (3, 0):
URLLIB = urllib.request
def download_and_extract(urls, data_dir):
print("\tstart download!")
for url in urls:
data_file = os.path.basename(url)
print(f'download file: {url}')
URLLIB.urlretrieve(url, filename=data_file)
with zipfile.ZipFile(file=data_file) as zip_ref:
zip_ref.extractall(data_dir)
os.remove(data_file)
print("\tCompleted!")
urls = [
'http://images.cocodataset.org/zips/train2014.zip',
'http://images.cocodataset.org/zips/val2014.zip',
'http://images.cocodataset.org/zips/test2014.zip',
'http://images.cocodataset.org/annotations/annotations_trainval2014.zip',
'http://images.cocodataset.org/annotations/image_info_test2014.zip'
]
parser = argparse.ArgumentParser()
parser.add_argument('--root', default='coco-2014', type=str, help='root directory')
args = parser.parse_args()
download_and_extract(urls, args.root)