-
Notifications
You must be signed in to change notification settings - Fork 233
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added rich-based progress bar #2132
Added rich-based progress bar #2132
Conversation
run pylint pre-commit tests |
Previously @vshampor expressed some concerns on |
return Text(text, style="progress.remaining") | ||
|
||
|
||
def track( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And need add option to use progressbar in async mode to manually update iterations
nncf/tests/post_training/pipelines/image_classification_timm.py
Lines 140 to 156 in 19d7260
with tqdm.tqdm(total=dataset_size, desc="Validation", disable=disable_tqdm) as pbar: | |
def process_result(request, userdata): | |
output_data = request.get_output_tensor().data | |
predicted_label = np.argmax(output_data, axis=1) | |
predictions[userdata] = [predicted_label] | |
pbar.update() | |
infer_queue.set_callback(process_result) | |
for i, (images, target) in enumerate(val_loader): | |
# W/A for memory leaks when using torch DataLoader and OpenVINO | |
image_copies = copy.deepcopy(images.numpy()) | |
infer_queue.start_async(image_copies, userdata=i) | |
references[i] = target | |
infer_queue.wait_all() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added this functionality by turning track
into a class with __iter__
, __enter__
and __exit__
implemented similarly to tqdm
. It can be used in the following way:
from nncf.common.logging.track_progress import track
n = 10000
with track(total=n, description="Description") as pbar:
for _ in range(n):
np.random.random((100000,))
pbar.progress.update(pbar.task, advance=1)
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## develop #2132 +/- ##
===========================================
+ Coverage 35.92% 36.23% +0.30%
===========================================
Files 476 477 +1
Lines 42483 42544 +61
===========================================
+ Hits 15264 15414 +150
+ Misses 27219 27130 -89
|
run pylint pre-commit tests |
### Changes - Progress bar now extends to screen width - Iteration count, time spent and time remaining text components are now Intel blue (RGB [0,104,181]) How it looks in terminal (Windows Terminal): ![image](https://github.com/openvinotoolkit/nncf/assets/23343961/cd10196a-ecdc-4b3a-a59e-b89341b6848c) How it looks in Jupyter: ![image](https://github.com/openvinotoolkit/nncf/assets/23343961/131e2e10-887e-45ac-8640-dd0752f37593) Please see how it looked before at #2132 Note: I've tried changing color for progress percent too, but couldn't, most probably due to a bug in rich Textualize/rich#3133 ### Reason for changes - Improving user experience Special thanks to @AlexanderDokuchaev and @kshpv for suggesting these changes.
Changes
Added
nncf.common.logging.track_progress.track()
method to replacetqdm
for quantization algorithms bars.This method is an almost exact copy of
rich.progress.track()
method, but with an addition of an iteration counter. This is kind of a hack, butrich
does not provide a way to add customColumn
objects to thetrack()
method.By default
rich.progress.track()
renders progress bar asWith an addition of customizations this becomes
With this change the quantization pipeline looks like
For iterables without length the progress bar displays as
How it looks in a notebook:
Reason for changes
tqdm
, for example:Statistics collection: 0%| | 0/300 [00:00<?, ?it/s]
Statistics collection: 0%| | 1/300 [00:00<01:13, 4.09it/s]
Statistics collection: 1%| | 2/300 [00:00<00:50, 5.87it/s]
Statistics collection: 1%|▏ | 4/300 [00:00<00:33, 8.79it/s]
Statistics collection: 2%|▏ | 6/300 [00:00<00:26, 11.30it/s]
Statistics collection: 3%|▎ | 8/300 [00:00<00:24, 11.88it/s]