Skip to content

Commit

Permalink
Add unzip flag to download() (ultralytics#3002)
Browse files Browse the repository at this point in the history
  • Loading branch information
glenn-jocher committed May 1, 2021
1 parent e4385f0 commit b4be85a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions utils/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,15 +183,15 @@ def check_dataset(dict):
raise Exception('Dataset not found.')


def download(url, dir='.', threads=1):
def download(url, dir='.', unzip=True, threads=1):
# Multi-threaded file download and unzip function
def download_one(url, dir):
# Download 1 file
f = dir / Path(url).name # filename
if not f.exists():
print(f'Downloading {url} to {f}...')
torch.hub.download_url_to_file(url, f, progress=True) # download
if f.suffix in ('.zip', '.gz'):
if unzip and f.suffix in ('.zip', '.gz'):
print(f'Unzipping {f}...')
if f.suffix == '.zip':
os.system(f'unzip -qo {f} -d {dir} && rm {f}') # unzip -quiet -overwrite
Expand Down

0 comments on commit b4be85a

Please sign in to comment.