Curl update (#3004)
Browse files* Curl update
* Curl update
- data/scripts/get_objects365.py +1 -1
- utils/general.py +5 -2
- utils/google_utils.py +1 -1
data/scripts/get_objects365.py
CHANGED
@@ -22,7 +22,7 @@ for p in 'images', 'labels':
|
|
22 |
# Download
|
23 |
url = "https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/train/"
|
24 |
download([url + 'zhiyuan_objv2_train.tar.gz'], dir=dir) # annotations json
|
25 |
-
download([url + f for f in [f'patch{i}.tar.gz' for i in range(51)]], dir=dir / 'images' / 'train', threads=8)
|
26 |
|
27 |
# Labels
|
28 |
coco = COCO(dir / 'zhiyuan_objv2_train.json')
|
|
|
22 |
# Download
|
23 |
url = "https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/train/"
|
24 |
download([url + 'zhiyuan_objv2_train.tar.gz'], dir=dir) # annotations json
|
25 |
+
download([url + f for f in [f'patch{i}.tar.gz' for i in range(51)]], dir=dir / 'images' / 'train', curl=True, threads=8)
|
26 |
|
27 |
# Labels
|
28 |
coco = COCO(dir / 'zhiyuan_objv2_train.json')
|
utils/general.py
CHANGED
@@ -183,14 +183,17 @@ def check_dataset(dict):
|
|
183 |
raise Exception('Dataset not found.')
|
184 |
|
185 |
|
186 |
-
def download(url, dir='.', unzip=True, threads=1):
|
187 |
# Multi-threaded file download and unzip function
|
188 |
def download_one(url, dir):
|
189 |
# Download 1 file
|
190 |
f = dir / Path(url).name # filename
|
191 |
if not f.exists():
|
192 |
print(f'Downloading {url} to {f}...')
|
193 |
-
|
|
|
|
|
|
|
194 |
if unzip and f.suffix in ('.zip', '.gz'):
|
195 |
print(f'Unzipping {f}...')
|
196 |
if f.suffix == '.zip':
|
|
|
183 |
raise Exception('Dataset not found.')
|
184 |
|
185 |
|
186 |
+
def download(url, dir='.', unzip=True, curl=False, threads=1):
|
187 |
# Multi-threaded file download and unzip function
|
188 |
def download_one(url, dir):
|
189 |
# Download 1 file
|
190 |
f = dir / Path(url).name # filename
|
191 |
if not f.exists():
|
192 |
print(f'Downloading {url} to {f}...')
|
193 |
+
if curl:
|
194 |
+
os.system(f"curl -L '{url}' -o '{f}' --retry 9 -C -") # curl download, retry and resume on fail
|
195 |
+
else:
|
196 |
+
torch.hub.download_url_to_file(url, f, progress=True) # torch download
|
197 |
if unzip and f.suffix in ('.zip', '.gz'):
|
198 |
print(f'Unzipping {f}...')
|
199 |
if f.suffix == '.zip':
|
utils/google_utils.py
CHANGED
@@ -47,7 +47,7 @@ def attempt_download(file, repo='ultralytics/yolov5'):
|
|
47 |
assert redundant, 'No secondary mirror'
|
48 |
url = f'https://storage.googleapis.com/{repo}/ckpt/{name}'
|
49 |
print(f'Downloading {url} to {file}...')
|
50 |
-
os.system(f
|
51 |
finally:
|
52 |
if not file.exists() or file.stat().st_size < 1E6: # check
|
53 |
file.unlink(missing_ok=True) # remove partial downloads
|
|
|
47 |
assert redundant, 'No secondary mirror'
|
48 |
url = f'https://storage.googleapis.com/{repo}/ckpt/{name}'
|
49 |
print(f'Downloading {url} to {file}...')
|
50 |
+
os.system(f"curl -L '{url}' -o '{file}' --retry 3 -C -") # curl download, retry and resume on fail
|
51 |
finally:
|
52 |
if not file.exists() or file.stat().st_size < 1E6: # check
|
53 |
file.unlink(missing_ok=True) # remove partial downloads
|