From 6939dafe691d91382dceb37c03f3a13bdc8e952e Mon Sep 17 00:00:00 2001 From: Songki Choi Date: Wed, 5 Apr 2023 15:28:19 +0900 Subject: [PATCH] Merge back bug fixes in release 1.1.2 (#1971) * Fix exception -> warning for anomaly dump_feature option * Remove `dataset.with_empty_annotations()` to keep original input structure (#1964) * Fix OV batch inference (saliency map generation) (#1965) * Release 1.1.2 RC1 * Fix classification model download logic to resolve zip issue (#1967) * Replace model download logic by pytorchcv to resolve zip issue * Update change log * Fix pre-commit * Configure checkpoint before model * Add pytorchcv to cls/seg requirement * Hot fix for numpy attr for ResultMediaEntity * Release 1.1.2 * Update exportable code demo commit --------- Co-authored-by: Evgeny Tsykunov --- CHANGELOG.md | 9 +++++++++ otx/algorithms/anomaly/tasks/inference.py | 2 +- .../classification/adapters/mmcls/tasks/stage.py | 2 +- otx/algorithms/classification/tasks/inference.py | 2 -- otx/algorithms/classification/tasks/openvino.py | 2 +- .../adapters/mmcv/models/backbones/efficientnet.py | 3 ++- otx/algorithms/detection/adapters/openvino/task.py | 2 +- otx/api/entities/result_media.py | 2 +- otx/api/usecases/exportable_code/demo/requirements.txt | 2 +- requirements/classification.txt | 1 + requirements/segmentation.txt | 1 + 11 files changed, 19 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dad16cdc88a..4e7fe78ec5a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,15 @@ All notable changes to this project will be documented in this file. - OpenVINO(==2022.3) IR inference is not working well on 2-stage models (e.g. Mask-RCNN) exported from torch==1.13.1 (working well up to torch==1.12.1) () +## \[v1.1.2\] + +### Bug fixes + +- Fix exception -> warning for anomaly dump_feature option +- Remove `dataset.with_empty_annotations()` to keep original input structure () +- Fix OV batch inference (saliency map generation) () +- Replace EfficentNetB0 model download logic by pytorchcv to resolve zip issue () + ## \[v1.1.1\] ### Bug fixes diff --git a/otx/algorithms/anomaly/tasks/inference.py b/otx/algorithms/anomaly/tasks/inference.py index 42d1a62f3f3..90d75e32081 100644 --- a/otx/algorithms/anomaly/tasks/inference.py +++ b/otx/algorithms/anomaly/tasks/inference.py @@ -266,7 +266,7 @@ def export( Exception: If export_type is not ExportType.OPENVINO """ if dump_features: - raise NotImplementedError( + logger.warning( "Feature dumping is not implemented for the anomaly task." "The saliency maps and representation vector outputs will not be dumped in the exported model." ) diff --git a/otx/algorithms/classification/adapters/mmcls/tasks/stage.py b/otx/algorithms/classification/adapters/mmcls/tasks/stage.py index 11dd3c9aefc..b2504f11daa 100644 --- a/otx/algorithms/classification/adapters/mmcls/tasks/stage.py +++ b/otx/algorithms/classification/adapters/mmcls/tasks/stage.py @@ -30,8 +30,8 @@ def configure(self, model_cfg, model_ckpt, data_cfg, training=True, **kwargs): # Recipe + model cfg = self.cfg - self.configure_model(cfg, model_cfg, **kwargs) self.configure_ckpt(cfg, model_ckpt, kwargs.get("pretrained", None)) + self.configure_model(cfg, model_cfg, **kwargs) self.configure_data(cfg, data_cfg, training) self.configure_task(cfg, training) return cfg diff --git a/otx/algorithms/classification/tasks/inference.py b/otx/algorithms/classification/tasks/inference.py index 6271602a0a2..e455cf2c6f2 100644 --- a/otx/algorithms/classification/tasks/inference.py +++ b/otx/algorithms/classification/tasks/inference.py @@ -127,7 +127,6 @@ def infer( logger.info("called infer()") stage_module = "ClsInferrer" self._data_cfg = self._init_test_data_cfg(dataset) - dataset = dataset.with_empty_annotations() dump_features = True dump_saliency_map = not inference_parameters.is_evaluation if inference_parameters else True @@ -169,7 +168,6 @@ def explain( logger.info("called explain()") stage_module = "ClsExplainer" self._data_cfg = self._init_test_data_cfg(dataset) - dataset = dataset.with_empty_annotations() results = self._run_task( stage_module, diff --git a/otx/algorithms/classification/tasks/openvino.py b/otx/algorithms/classification/tasks/openvino.py index c61e64140d5..5e52e7aee4e 100644 --- a/otx/algorithms/classification/tasks/openvino.py +++ b/otx/algorithms/classification/tasks/openvino.py @@ -273,7 +273,7 @@ def explain( dataset_item.append_labels(item_labels) add_saliency_maps_to_dataset_item( dataset_item=dataset_item, - saliency_map=np.copy(saliency_map), + saliency_map=saliency_map, model=self.model, labels=self.task_environment.get_labels(), predicted_scored_labels=item_labels, diff --git a/otx/algorithms/common/adapters/mmcv/models/backbones/efficientnet.py b/otx/algorithms/common/adapters/mmcv/models/backbones/efficientnet.py index 1b24a7da763..13ca6eb1c3c 100644 --- a/otx/algorithms/common/adapters/mmcv/models/backbones/efficientnet.py +++ b/otx/algorithms/common/adapters/mmcv/models/backbones/efficientnet.py @@ -18,6 +18,7 @@ from mmcv.cnn import build_activation_layer from mmcv.cnn.bricks import ConvModule from mmcv.runner import load_checkpoint +from pytorchcv.models.model_store import download_model from torch import nn from torch.nn import init @@ -1308,5 +1309,5 @@ def init_weights(self, pretrained=None): load_checkpoint(self, pretrained) logger.info(f"init weight - {pretrained}") elif pretrained is not None: - load_checkpoint(self, pretrained_urls[self.model_name]) + download_model(net=self, model_name=self.model_name) logger.info(f"init weight - {pretrained_urls[self.model_name]}") diff --git a/otx/algorithms/detection/adapters/openvino/task.py b/otx/algorithms/detection/adapters/openvino/task.py index 694d947b1b4..09d7036f398 100644 --- a/otx/algorithms/detection/adapters/openvino/task.py +++ b/otx/algorithms/detection/adapters/openvino/task.py @@ -465,7 +465,7 @@ def explain( add_saliency_maps_to_dataset_item( dataset_item=dataset_item, - saliency_map=np.copy(saliency_map), + saliency_map=saliency_map, model=self.model, labels=labels, predicted_scored_labels=predicted_scored_labels, diff --git a/otx/api/entities/result_media.py b/otx/api/entities/result_media.py index fe2f090bbda..6079f3da48f 100644 --- a/otx/api/entities/result_media.py +++ b/otx/api/entities/result_media.py @@ -82,7 +82,7 @@ def __init__( self.annotation_scene = annotation_scene self.roi = Annotation(Rectangle.generate_full_box(), labels=[]) if roi is None else roi self.label = label - self.numpy = numpy + self._numpy = np.copy(numpy) def __repr__(self): """Returns a string with all the attributes of the ResultMediaEntity.""" diff --git a/otx/api/usecases/exportable_code/demo/requirements.txt b/otx/api/usecases/exportable_code/demo/requirements.txt index 9fbe16dfffe..f0bba0497d7 100644 --- a/otx/api/usecases/exportable_code/demo/requirements.txt +++ b/otx/api/usecases/exportable_code/demo/requirements.txt @@ -1,4 +1,4 @@ openvino==2022.3.0 openmodelzoo-modelapi==2022.3.0 -otx @ git+https://github.com/openvinotoolkit/training_extensions/@9753acd6fef11fa83240e6ed3a031fb9a3e62b0f#egg=otx +otx @ git+https://github.com/openvinotoolkit/training_extensions/@dd03235da2319815227f1b75bce298ee6e8b0f31#egg=otx numpy>=1.21.0,<=1.23.5 # np.bool was removed in 1.24.0 which was used in openvino runtime diff --git a/requirements/classification.txt b/requirements/classification.txt index 3efc94c8a9e..f65df21b120 100644 --- a/requirements/classification.txt +++ b/requirements/classification.txt @@ -4,3 +4,4 @@ mmcv-full==1.7.0 mmcls==0.25.0 timm otxdeploy==0.12.1 # FIXME: mmdeploy==? when PyPI packages are available +pytorchcv diff --git a/requirements/segmentation.txt b/requirements/segmentation.txt index fcf033eb799..34980f90081 100644 --- a/requirements/segmentation.txt +++ b/requirements/segmentation.txt @@ -5,3 +5,4 @@ mmsegmentation==0.30.0 scikit-image otxdeploy==0.12.1 # FIXME: mmdeploy==? when PyPI packages are available timm +pytorchcv