Skip to content

Commit

Permalink
downloader: better progress bar
Browse files Browse the repository at this point in the history
  • Loading branch information
oobabooga committed Jul 29, 2024
1 parent 9dcff21 commit f4d95f3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions download-model.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,11 +212,15 @@ def get_single_file(self, url, output_folder, start_from_scratch=False):
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:
Expand All @@ -233,7 +237,7 @@ def get_single_file(self, url, output_folder, start_from_scratch=False):
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:
Expand Down

0 comments on commit f4d95f3

Please sign in to comment.