Skip to content

Commit

Permalink
Better progress bar for file downloading (#8556)
Browse files Browse the repository at this point in the history
Co-authored-by: Nicolas Hug <[email protected]>
  • Loading branch information
mshr-h and NicolasHug authored Jul 30, 2024
1 parent ef8c0f6 commit 478c670
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion torchvision/datasets/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

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

0 comments on commit 478c670

Please sign in to comment.