Commit 47214f05 authored by Maruth Goyal's avatar Maruth Goyal Committed by Soumith Chintala
Browse files

Progress Bar for download_url (#497)

* Added Progress Bar to the dataset downloading utility

* Updated progressbar to update by blcoks

* Added progressbar2 to the requirements

* fixed style issues

* Shifted from progressbar to tqdm
parent 73281b4f
......@@ -33,6 +33,7 @@ requirements = [
'pillow >= 4.1.1',
'six',
'torch',
'tqdm'
]
setup(
......
......@@ -2,6 +2,15 @@ import os
import os.path
import hashlib
import errno
from tqdm import tqdm
def gen_bar_updator(pbar):
def bar_update(count, block_size, total_size):
pbar.total = total_size / block_size
pbar.update(count)
return bar_update
def check_integrity(fpath, md5):
......@@ -38,7 +47,7 @@ def download_url(url, root, filename, md5):
else:
try:
print('Downloading ' + url + ' to ' + fpath)
urllib.request.urlretrieve(url, fpath)
urllib.request.urlretrieve(url, fpath, reporthook=gen_bar_updator(tqdm()))
except:
if url[:5] == 'https':
url = url.replace('https:', 'http:')
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment