From f4d95f33b80ba1fa6f69590ffe9ddff014dbca1a Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Sun, 28 Jul 2024 22:21:56 -0700 Subject: [PATCH] downloader: better progress bar --- download-model.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/download-model.py b/download-model.py index 08b23d08..0014b689 100644 --- a/download-model.py +++ b/download-model.py @@ -212,11 +212,15 @@ class ModelDownloader: total_size = int(r.headers.get('content-length', 0)) block_size = 1024 * 1024 # 1MB + filename_str = str(filename) # Convert PosixPath to string if necessary + tqdm_kwargs = { 'total': total_size, - 'unit': 'iB', + 'unit': 'B', 'unit_scale': True, - 'bar_format': '{l_bar}{bar}| {n_fmt}/{total_fmt} {rate_fmt}' + 'unit_divisor': 1024, + 'bar_format': '{desc}{percentage:3.0f}%|{bar:50}| {n_fmt}/{total_fmt} [{elapsed}<{remaining}, {rate_fmt}]', + 'desc': f"{filename_str}: " } if 'COLAB_GPU' in os.environ: @@ -233,7 +237,7 @@ class ModelDownloader: t.update(len(data)) if total_size != 0 and self.progress_bar is not None: count += len(data) - self.progress_bar(float(count) / float(total_size), f"{filename}") + self.progress_bar(float(count) / float(total_size), f"{filename_str}") break # Exit loop if successful except (RequestException, ConnectionError, Timeout) as e: