Skip to content

Commit

Permalink
Mergeback 1.4.2rc5 (#2511)
Browse files Browse the repository at this point in the history
* Bug fix for albumentations (#2467)

* bug fix for legacy openvino models

* Add a dummy hierarchical config required by MAPI (#2483)

* Bump datumaro version (#2502)

* Upgrade nncf version (#2459)

* Update FQ refs after NNCF upgrade

---------

Co-authored-by: Ashwin Vaidya <ashwin.vaidya@intel.com>
Co-authored-by: Ashwin Vaidya <ashwinitinvaidya@gmail.com>
Co-authored-by: Vladislav Sovrasov <sovrasov.vlad@gmail.com>
  • Loading branch information
4 people authored Sep 20, 2023
1 parent 6f00907 commit 12bf332
Show file tree
Hide file tree
Showing 14 changed files with 74 additions and 18 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,21 @@ All notable changes to this project will be documented in this file.
- OpenVINO(==2023.0) IR inference is not working well on 2-stage models (e.g. Mask-RCNN) exported from torch>=1.13.1
- NNCF QAT optimization is disabled for MaskRCNN models due to CUDA runtime error in ROIAlign kernel on torch==2.0.1

## \[v1.4.2\]

### Enhancements

- Bump datumaro version to 1.5.0rc0 (<https://github.com/openvinotoolkit/training_extensions/pull/2470>)
- Set tox version constraint (<https://github.com/openvinotoolkit/training_extensions/pull/2472>)
- Add model category attributes to model template (<https://github.com/openvinotoolkit/training_extensions/pull/2439>)

### Bug fixes

- Bug fix for albumentations (<https://github.com/openvinotoolkit/training_extensions/pull/2467>)
- Add workaround for the incorrect meta info M-RCNN (used for XAI) (<https://github.com/openvinotoolkit/training_extensions/pull/2437>)
- Fix label list order for h-label classification (<https://github.com/openvinotoolkit/training_extensions/pull/2440>)
- Modified fq numbers for lite HRNET e2e tests (<https://github.com/openvinotoolkit/training_extensions/pull/2445>)

## \[v1.4.1\]

### Enhancements
Expand Down
9 changes: 8 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,21 @@
# documentation root, use os.path.abspath to make it absolute, like shown here.
#

import os
import sys

sys.path.insert(0, os.path.abspath("../../src"))

from otx import __version__

# ruff: noqa

# -- Project information ----------------------------------------------------- #

project = 'OpenVINO™ Training Extensions'
copyright = '2023, OpenVINO™ Training Extensions Contributors'
author = 'OpenVINO™ Training Extensions Contributors'
release = '1.5.0'
release = __version__

# -- General configuration --------------------------------------------------- #

Expand Down
2 changes: 1 addition & 1 deletion requirements/base.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ natsort>=6.0.0
prettytable
protobuf>=3.20.0
pyyaml
datumaro==1.5.0rc0
datumaro~=1.5.0
psutil
scipy>=1.8
bayesian-optimization>=1.2.0
Expand Down
2 changes: 1 addition & 1 deletion requirements/openvino.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
# OpenVINO Requirements. #
nncf==2.5.0
nncf==2.6.0
onnx==1.13.0
openvino-model-api==0.1.5
openvino==2023.0
Expand Down
3 changes: 2 additions & 1 deletion src/otx/algorithms/anomaly/tasks/openvino.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,8 @@ def _populate_metadata_legacy(self, model: ModelEntity) -> Dict[str, Any]:
to_tensor=True,
)
metadata = {
"transform": transform.to_dict(),
# TODO: Replace with transform.to_dict() when OTX supports albumentations 1.3.0
"transform": {"transform": transform._to_dict()},
"image_threshold": image_threshold,
"pixel_threshold": pixel_threshold,
"min": min_value,
Expand Down
15 changes: 14 additions & 1 deletion src/otx/algorithms/classification/adapters/openvino/task.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
from otx.algorithms.classification.configs import ClassificationConfig
from otx.algorithms.classification.utils import (
get_cls_deploy_config,
get_cls_inferencer_configuration,
get_hierarchical_label_list,
)
from otx.algorithms.common.utils import OTXOpenVinoDataLoader
Expand Down Expand Up @@ -113,7 +114,19 @@ def __init__(
max_num_requests=num_requests,
plugin_config={"PERFORMANCE_HINT": "THROUGHPUT"},
)
self.model = Model.create_model(model_adapter, "Classification", {}, preload=True)
self.configuration = get_cls_inferencer_configuration(self.label_schema)

# create a dummy hierarchical config for backward compatibility, which is not actually used
if self.configuration["hierarchical"]:
try:
model_adapter.get_rt_info(["model_info", "hierarchical_config"])
except RuntimeError:
self.configuration["hierarchical_config"] = json.dumps(
{"cls_heads_info": {"label_to_idx": [], "all_groups": []}, "label_tree_edges": []}
)

self.model = Model.create_model(model_adapter, "Classification", self.configuration, preload=True)

self.converter = ClassificationToAnnotationConverter(self.label_schema)
self.callback_exceptions: List[Exception] = []
self.model.inference_adapter.set_callback(self._async_callback)
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algorithms/common/tasks/nncf_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ def model_builder(

if is_export:
compression_ctrl.prepare_for_export()
model.disable_dynamic_graph_building()
model.nncf.disable_dynamic_graph_building()

if return_compression_ctrl:
return compression_ctrl, model
Expand Down
2 changes: 1 addition & 1 deletion src/otx/api/usecases/exportable_code/demo/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
openvino==2023.0
openvino-model-api==0.1.5
otx @ git+https://github.com/sovrasov/openvino_training_extensions/@38a9d7b20e3359d6139616c7127eac98d304c9f6#egg=otx
otx @ git+https://github.com/openvinotoolkit/training_extensions/@e066a04834952257c1c9384a09f472d13b76b264#egg=otx
numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ TestToolsAnomalyClassification:
number_of_fakequantizers: 26
ptq:
number_of_fakequantizers: 27
pot:
number_of_fakequantizers: 28
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ TestToolsAnomalyDetection:
number_of_fakequantizers: 26
ptq:
number_of_fakequantizers: 27
pot:
number_of_fakequantizers: 28
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ TestToolsAnomalySegmentation:
number_of_fakequantizers: 26
ptq:
number_of_fakequantizers: 27
pot:
number_of_fakequantizers: 28
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ TestToolsOTXInstanceSegmentation:
number_of_fakequantizers: 204
ptq:
number_of_fakequantizers: 174
pot:
number_of_fakequantizers: 137
TestToolsTilingInstanceSegmentation:
nncf:
number_of_fakequantizers: 204
ptq:
number_of_fakequantizers: 174
pot:
number_of_fakequantizers: 137
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,12 @@ TestToolsOTXInstanceSegmentation:
number_of_fakequantizers: 97
ptq:
number_of_fakequantizers: 136
pot:
number_of_fakequantizers: 99
TestToolsTilingInstanceSegmentation:
nncf:
number_of_fakequantizers: 97
ptq:
number_of_fakequantizers: 136
pot:
number_of_fakequantizers: 99
28 changes: 17 additions & 11 deletions tests/unit/core/data/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@
import os

import cv2
import datumaro as dm
import numpy as np
from datumaro.components.annotation import Label, Bbox, Mask
from datumaro.components.dataset import Dataset
from datumaro.components.dataset_base import DatasetItem
from datumaro.components.media import ImageFromFile, ImageFromNumpy


from otx.api.entities.model_template import TaskType

Expand Down Expand Up @@ -107,7 +111,7 @@ def generate_datumaro_dataset_item(
image_shape: np.array = np.array((5, 5, 3)),
mask_shape: np.array = np.array((5, 5)),
temp_dir: Optional[str] = None,
) -> dm.DatasetItem:
) -> DatasetItem:
"""Generate Datumaro DatasetItem.
Args:
Expand All @@ -119,20 +123,22 @@ def generate_datumaro_dataset_item(
temp_dir (str): directory to save image data
Returns:
dm.DatasetItem: Datumaro DatasetItem
DatasetItem: Datumaro DatasetItem
"""
ann_task_dict = {
"classification": dm.Label(label=0),
"detection": dm.Bbox(1, 2, 3, 4, label=0),
"segmentation": dm.Mask(np.zeros(mask_shape)),
"classification": Label(label=0),
"detection": Bbox(1, 2, 3, 4, label=0),
"segmentation": Mask(np.zeros(mask_shape)),
}

if temp_dir:
path = os.path.join(temp_dir, "image.png")
cv2.imwrite(path, np.ones(image_shape))
return dm.DatasetItem(id=item_id, subset=subset, image=path, annotations=[ann_task_dict[task]])
return DatasetItem(id=item_id, subset=subset, media=ImageFromFile(path), annotations=[ann_task_dict[task]])

return dm.DatasetItem(id=item_id, subset=subset, image=np.ones(image_shape), annotations=[ann_task_dict[task]])
return DatasetItem(
id=item_id, subset=subset, media=ImageFromNumpy(np.ones(image_shape)), annotations=[ann_task_dict[task]]
)


def generate_datumaro_dataset(
Expand All @@ -141,7 +147,7 @@ def generate_datumaro_dataset(
num_data: int = 1,
image_shape: np.array = np.array((5, 5, 3)),
mask_shape: np.array = np.array((5, 5)),
) -> dm.Dataset:
) -> Dataset:
"""Generate Datumaro Dataset.
Args:
Expand All @@ -154,7 +160,7 @@ def generate_datumaro_dataset(
Returns:
dm.Dataset: Datumaro Dataset
"""
dataset_items: dm.DatasetItem = []
dataset_items: DatasetItem = []
for subset in subsets:
for idx in range(num_data):
dataset_items.append(
Expand All @@ -166,4 +172,4 @@ def generate_datumaro_dataset(
mask_shape=mask_shape,
)
)
return dm.Dataset.from_iterable(dataset_items, categories=["cat", "dog"])
return Dataset.from_iterable(dataset_items, categories=["cat", "dog"])

0 comments on commit 12bf332

Please sign in to comment.