-
Notifications
You must be signed in to change notification settings - Fork 446
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Enable balanced sampler for class incremental learning in classification
- gh-pages
- (#1139)
- poc/conifg-param
- (#1139)
- releases/1.1.0
- (#1139)
- releases/1.1.1
- (#1139)
- releases/1.1.2
- (#1139)
- releases/1.2.0
- (#1139)
- releases/1.2.1
- (#1139)
- releases/1.2.2
- (#1139)
- releases/1.2.3
- (#1139)
- releases/1.2.4
- (#1139)
- releases/1.3.0
- (#1139)
- releases/1.3.1
- (#1139)
- releases/1.3.2
- (#1139)
- releases/1.4.0
- (#1139)
- releases/1.5.0
- (#1139)
- releases/1.6.0
- (#1139)
- releases/v0.4.0-geti1.1.0
- (#1139)
- releases/v1.0.0
- (#1139)
Showing
6 changed files
with
50 additions
and
27 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
29 changes: 29 additions & 0 deletions
29
external/model-preparation-algorithm/mpa_tasks/utils/data_utils.py
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,29 @@ | ||
# Copyright (C) 2022 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
# | ||
|
||
from mpa.utils.logger import get_logger | ||
|
||
logger = get_logger() | ||
|
||
|
||
def get_cls_img_indices(labels, dataset): | ||
img_indices = {label.name: list() for label in labels} | ||
for i, item in enumerate(dataset): | ||
item_labels = item.annotation_scene.get_labels() | ||
for i_l in item_labels: | ||
img_indices[i_l.name].append(i) | ||
|
||
return img_indices | ||
|
||
|
||
def get_old_new_img_indices(labels, new_classes, dataset): | ||
ids_old, ids_new = [], [] | ||
_dataset_label_schema_map = {label.name: label for label in labels} | ||
new_classes = [_dataset_label_schema_map[new_class] for new_class in new_classes] | ||
for i, item in enumerate(dataset): | ||
if item.annotation_scene.contains_any(new_classes): | ||
ids_new.append(i) | ||
else: | ||
ids_old.append(i) | ||
return {'old': ids_old, 'new': ids_new} |
Submodule submodule
updated
3 files
+3 −2 | mpa/cls/stage.py | |
+65 −0 | mpa/modules/datasets/samplers/balanced_sampler.py | |
+8 −2 | mpa/modules/hooks/task_adapt_hook.py |