1 parent
4d7bca7648
commit
37eaffec7d
3 files changed
+7
-4
No files matched your search
@@ -22,7 +22,7 @@ for p in 'images', 'labels':
|
|||||||
# Download
|
# Download
|
||||||
url = "https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/train/"
|
url = "https://dorc.ks3-cn-beijing.ksyun.com/data-set/2020Objects365%E6%95%B0%E6%8D%AE%E9%9B%86/train/"
|
||||||
download([url + 'zhiyuan_objv2_train.tar.gz'], dir=dir) # annotations json
|
download([url + 'zhiyuan_objv2_train.tar.gz'], dir=dir) # annotations json
|
||||||
download([url + f for f in [f'patch{i}.tar.gz' for i in range(51)]], dir=dir / 'images' / 'train', threads=8)
|
download([url + f for f in [f'patch{i}.tar.gz' for i in range(51)]], dir=dir / 'images' / 'train', curl=True, threads=8)
|
||||||
|
|
||||||
# Labels
|
# Labels
|
||||||
coco = COCO(dir / 'zhiyuan_objv2_train.json')
|
coco = COCO(dir / 'zhiyuan_objv2_train.json')
|
||||||
|
|||||||
+5
-2
@@ -183,14 +183,17 @@ def check_dataset(dict):
|
|||||||
raise Exception('Dataset not found.')
|
raise Exception('Dataset not found.')
|
||||||
|
|
||||||
|
|
||||||
def download(url, dir='.', unzip=True, threads=1):
|
def download(url, dir='.', unzip=True, curl=False, threads=1):
|
||||||
# Multi-threaded file download and unzip function
|
# Multi-threaded file download and unzip function
|
||||||
def download_one(url, dir):
|
def download_one(url, dir):
|
||||||
# Download 1 file
|
# Download 1 file
|
||||||
f = dir / Path(url).name # filename
|
f = dir / Path(url).name # filename
|
||||||
if not f.exists():
|
if not f.exists():
|
||||||
print(f'Downloading {url} to {f}...')
|
print(f'Downloading {url} to {f}...')
|
||||||
torch.hub.download_url_to_file(url, f, progress=True) # download
|
if curl:
|
||||||
|
os.system(f"curl -L '{url}' -o '{f}' --retry 9 -C -") # curl download, retry and resume on fail
|
||||||
|
else:
|
||||||
|
torch.hub.download_url_to_file(url, f, progress=True) # torch download
|
||||||
if unzip and f.suffix in ('.zip', '.gz'):
|
if unzip and f.suffix in ('.zip', '.gz'):
|
||||||
print(f'Unzipping {f}...')
|
print(f'Unzipping {f}...')
|
||||||
if f.suffix == '.zip':
|
if f.suffix == '.zip':
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ def attempt_download(file, repo='ultralytics/yolov5'):
|
|||||||
assert redundant, 'No secondary mirror'
|
assert redundant, 'No secondary mirror'
|
||||||
url = f'https://storage.googleapis.com/{repo}/ckpt/{name}'
|
url = f'https://storage.googleapis.com/{repo}/ckpt/{name}'
|
||||||
print(f'Downloading {url} to {file}...')
|
print(f'Downloading {url} to {file}...')
|
||||||
os.system(f'curl -L {url} -o {file}') # torch.hub.download_url_to_file(url, weights)
|
os.system(f"curl -L '{url}' -o '{file}' --retry 3 -C -") # curl download, retry and resume on fail
|
||||||
finally:
|
finally:
|
||||||
if not file.exists() or file.stat().st_size < 1E6: # check
|
if not file.exists() or file.stat().st_size < 1E6: # check
|
||||||
file.unlink(missing_ok=True) # remove partial downloads
|
file.unlink(missing_ok=True) # remove partial downloads
|
||||||
|
|||||||
Reference in new issue
Block a user