Skip to content

Commit

Permalink
[fbsync] Better progress bar for file downloading (#8556)
Browse files Browse the repository at this point in the history
Summary: Co-authored-by: Nicolas Hug <[email protected]>

Reviewed By: vmoens

Differential Revision: D60596228

fbshipit-source-id: 22a4683f8f4ca1866811ccef4169d2e6d93215b7
  • Loading branch information
NicolasHug authored and facebook-github-bot committed Aug 2, 2024
1 parent 4065dac commit 16413b1
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 16413b1

Please sign in to comment.