Skip to content

Commit 478c670

Browse files
mshr-hNicolasHug
andauthored
Better progress bar for file downloading (#8556)
Co-authored-by: Nicolas Hug <[email protected]>
1 parent ef8c0f6 commit 478c670

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torchvision/datasets/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
def _urlretrieve(url: str, filename: Union[str, pathlib.Path], chunk_size: int = 1024 * 32) -> None:
2828
with urllib.request.urlopen(urllib.request.Request(url, headers={"User-Agent": USER_AGENT})) as response:
29-
with open(filename, "wb") as fh, tqdm(total=response.length) as pbar:
29+
with open(filename, "wb") as fh, tqdm(total=response.length, unit="B", unit_scale=True) as pbar:
3030
while chunk := response.read(chunk_size):
3131
fh.write(chunk)
3232
pbar.update(len(chunk))

0 commit comments

Comments
 (0)