Skip to content

Commit

Permalink
better progress bar for file downloading
Browse files Browse the repository at this point in the history
  • Loading branch information
mshr-h authored Jul 30, 2024
1 parent 845bb61 commit 021ccf2
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 021ccf2

Please sign in to comment.