forked from openvinotoolkit/nncf
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tqdm progress bar improvements (openvinotoolkit#2114)
### Changes 1. Fixed an issue with wrong `tqdm` bar length in the case when calibration dataset length is less than `subset_size`. Reproducer: nikita-savelyevv@f0951c1 **Before:** `Statistics collection: 34%|██████ | 101/300 [00:03<00:06, 28.66it/s]` **After:** When dataset has `__len__`: `Statistics collection: 100%|██████████████████| 101/101 [00:03<00:00, 28.20it/s]` When dataset doesn't have `__len__`: `Statistics collection: 34%|██████ | 101/300 [00:03<00:06, 29.45it/s]` 2. Improved progress bar GUI when ran from notebooks. **Before:** <img width="704" alt="Screenshot 2023-09-06 091857" src="https://github.com/openvinotoolkit/nncf/assets/23343961/9851cb8d-00f1-4297-af50-14697e86e961"> or (in some browsers progress bar takes up multiple lines): ![image](https://github.com/openvinotoolkit/nncf/assets/23343961/99fa9629-2869-4d8f-872e-97ef59bc092e) **After:** <img width="706" alt="Screenshot 2023-09-06 105453" src="https://github.com/openvinotoolkit/nncf/assets/23343961/58e75cc9-2507-4c5b-8c3c-cac44eefcb79"> In console the progress bar is the same. ### Reason for changes User experience improvement. ### Related tickets 112627 ### Tests <!--- How was the correctness of changes tested and whether new tests were added -->
- Loading branch information
1 parent
8400793
commit 0a08966
Showing
7 changed files
with
84 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# Copyright (c) 2023 Intel Corporation | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
from nncf import Dataset | ||
|
||
|
||
def test_dataset(): | ||
raw_data = list(range(50)) | ||
dataset = Dataset(raw_data) | ||
|
||
data_provider = dataset.get_data() | ||
retrieved_data_items = list(data_provider) | ||
assert all(raw_data[i] == retrieved_data_items[i] for i in range(len(raw_data))) | ||
|
||
|
||
def test_dataset_with_transform_func(): | ||
raw_data = list(range(50)) | ||
dataset = Dataset(raw_data, transform_func=lambda it: 2 * it) | ||
|
||
data_provider = dataset.get_inference_data() | ||
retrieved_data_items = list(data_provider) | ||
assert all(2 * raw_data[i] == retrieved_data_items[i] for i in range(len(raw_data))) | ||
|
||
|
||
def test_dataset_with_indices(): | ||
raw_data = list(range(50)) | ||
dataset = Dataset(raw_data) | ||
|
||
data_provider = dataset.get_data(indices=list(range(0, 50, 2))) | ||
retrieved_data_items = list(data_provider) | ||
assert all(raw_data[2 * i] == retrieved_data_items[i] for i in range(len(raw_data) // 2)) | ||
|
||
|
||
def test_dataset_with_transform_func_with_indices(): | ||
raw_data = list(range(50)) | ||
dataset = Dataset(raw_data, transform_func=lambda it: 2 * it) | ||
|
||
data_provider = dataset.get_inference_data(indices=list(range(0, 50, 2))) | ||
retrieved_data_items = list(data_provider) | ||
assert all(2 * raw_data[2 * i] == retrieved_data_items[i] for i in range(len(raw_data) // 2)) | ||
|
||
|
||
def test_dataset_without_length(): | ||
raw_data = list(range(50)) | ||
dataset_with_length = Dataset(raw_data) | ||
dataset_without_length = Dataset(iter(raw_data)) | ||
assert dataset_with_length.get_length() == 50 | ||
assert dataset_without_length.get_length() is None | ||
|
||
data_provider = dataset_with_length.get_data() | ||
retrieved_data_items = list(data_provider) | ||
assert all(raw_data[i] == retrieved_data_items[i] for i in range(len(raw_data))) | ||
|
||
data_provider = dataset_without_length.get_data() | ||
retrieved_data_items = list(data_provider) | ||
assert all(raw_data[i] == retrieved_data_items[i] for i in range(len(raw_data))) |