Skip to content

Commit

Permalink
merge develop
Browse files Browse the repository at this point in the history
  • Loading branch information
kprokofi committed May 2, 2024
2 parents 360ccd0 + 82f3ddb commit 26cc9b0
Show file tree
Hide file tree
Showing 172 changed files with 3,995 additions and 3,980 deletions.
10 changes: 5 additions & 5 deletions .ci/requirements/publish/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
build==1.1.1 \
--hash=sha256:8ed0851ee76e6e38adce47e4bee3b51c771d86c64cf578d0c2245567ee200e73 \
--hash=sha256:8eea65bb45b1aac2e734ba2cc8dad3a6d97d97901a395bd0ed3e7b46953d2a31
# via -r .ci/publish-deps.in
# via -r requirements.in
certifi==2024.2.2 \
--hash=sha256:0569859f95fc761b18b45ef421b1290a0f65f147e92a1e5eb3e635f9a5e4e66f \
--hash=sha256:dc383c07b76109f368f6106eee2b593b04a011ea4d55f652c6ca24a754d1cdd1
Expand Down Expand Up @@ -196,9 +196,9 @@ docutils==0.20.1 \
--hash=sha256:96f387a2c5562db4476f09f13bbab2192e764cac08ebbf3a34a95d9b1e4a59d6 \
--hash=sha256:f08a4e276c3a1583a86dce3e34aba3fe04d02bba2dd51ed16106244e8a923e3b
# via readme-renderer
idna==3.6 \
--hash=sha256:9ecdbbd083b06798ae1e86adcbfe8ab1479cf864e4ee30fe4e46a003d12491ca \
--hash=sha256:c05567e9c24a6b9faaa835c4821bad0590fbb9d5779e7caa6e1cc4978e7eb24f
idna==3.7 \
--hash=sha256:028ff3aadf0609c1fd278d8ea3089299412a7a8b9bd005dd08b9f8285bcb5cfc \
--hash=sha256:82fee1fc78add43492d3a1898bfa6d8a904cc97d8427f683ed8e798d07761aa0
# via requests
importlib-metadata==7.0.2 \
--hash=sha256:198f568f3230878cb1b44fbd7975f87906c22336dba2e4a7f05278c281fbd792 \
Expand Down Expand Up @@ -307,7 +307,7 @@ tomli==2.0.1 \
twine==5.0.0 \
--hash=sha256:89b0cc7d370a4b66421cc6102f269aa910fe0f1861c124f573cf2ddedbc10cf4 \
--hash=sha256:a262933de0b484c53408f9edae2e7821c1c45a3314ff2df9bdd343aa7ab8edc0
# via -r .ci/publish-deps.in
# via -r requirements.in
urllib3==2.2.1 \
--hash=sha256:450b20ec296a467077128bff42b73080516e71b56ff59a60a02bef2232c4fa9d \
--hash=sha256:d0570876c61ab9e520d776c38acbbb5b05a776d3f9ff98a5c8fd5162a444cf19
Expand Down
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
!LICENSE
!MANIFEST.in
!docker/download_pretrained_weights.py
!.ci
48 changes: 48 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,54 @@ All notable changes to this project will be documented in this file.

### Enhancements

## \[v1.6.1\]

### Enhancements

- Update pymongo version to 4.6.3 for resolving CVE-2024-21506
(<https://github.com/openvinotoolkit/training_extensions/pull/3396>)
- Use torchvision in MRCNN on CUDA
(<https://github.com/openvinotoolkit/training_extensions/pull/3347>)
- Update IPEX version in installation guide documentation
(<https://github.com/openvinotoolkit/training_extensions/pull/3343>)
- Update benchmark
(<https://github.com/openvinotoolkit/training_extensions/pull/3338>)
- Bump idan version to 3.7
(<https://github.com/openvinotoolkit/training_extensions/pull/3332>)
- Support benchmark history summary
(<https://github.com/openvinotoolkit/training_extensions/pull/3307>)
- Pin pymongo version to 4.5.0
(<https://github.com/openvinotoolkit/training_extensions/pull/3316>)
- Upgrade MAPI
(<https://github.com/openvinotoolkit/training_extensions/pull/3304>)
- Add NMS iou threshold configurable parameter
(<https://github.com/openvinotoolkit/training_extensions/pull/3287>)
- Remedy some medium/low severity bandit issues
(<https://github.com/openvinotoolkit/training_extensions/pull/3208>)
- Update documentations
(<https://github.com/openvinotoolkit/training_extensions/pull/3280>)
- Add perf benchmark test cases for action and visual prompting
(<https://github.com/openvinotoolkit/training_extensions/pull/3292>)

### Bug fixes

- Explicitly cast incorrect output type in OV model
(<https://github.com/openvinotoolkit/training_extensions/pull/3395>)
- Update QAT configs for rotated detection
(<https://github.com/openvinotoolkit/training_extensions/pull/3375>)
- Hotfix :wrench: Bypass ClsIncrSampler for tiling
(<https://github.com/openvinotoolkit/training_extensions/pull/3374>)
- [NNCF] Dynamic shape datasets WA
(<https://github.com/openvinotoolkit/training_extensions/pull/3355>)
- [Hotfix] :fire: Fixing detection oriented OV inferencer
(<https://github.com/openvinotoolkit/training_extensions/pull/3351>)
- Revert adaptive batch size
(<https://github.com/openvinotoolkit/training_extensions/pull/3340>)
- Fix e2e tests for XPU
(<https://github.com/openvinotoolkit/training_extensions/pull/3305>)
- Remove torch.xpu.optimize for semantic_segmentation task
(<https://github.com/openvinotoolkit/training_extensions/pull/3172>)

## \[1.6.0\]

### New features
Expand Down
33 changes: 31 additions & 2 deletions docs/source/guide/release_notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,37 @@ Releases
:maxdepth: 1


v2.0.0 (1Q24)
v2.0.0 (2Q24)
-------------

v1.6.1 (2024.05)
----------------

Enhancements
^^^^^^^^^^^^
- Update pymongo version to 4.6.3 for resolving CVE-2024-21506
- Use torchvision in MRCNN on CUDA
- Update IPEX version in installation guide documentation
- Update benchmark
- Bump idan version to 3.7
- Support benchmark history summary
- Upgrade MAPI
- Add NMS iou threshold configurable parameter
- Remedy some medium/low severity bandit issues
- Update documentations
- Add perf benchmark test cases for action and visual prompting

Bug fixes
^^^^^^^^^
- Explicitly cast incorrect output type in OV model
- Update QAT configs for rotated detection
- Hotfix :wrench: Bypass ClsIncrSampler for tiling
- [NNCF] Dynamic shape datasets WA
- [Hotfix] :fire: Fixing detection oriented OV inferencer
- Revert adaptive batch size
- Fix e2e tests for XPU
- Remove torch.xpu.optimize for semantic_segmentation task

v1.6.0 (2024.04)
----------------

Expand Down Expand Up @@ -59,7 +87,6 @@ v1.5.2 (2024.01)

Enhancements
^^^^^^^^^^^^

- Add memory bounded datumaro data format detect
- Remove Protobuf version limitation (<4)

Expand Down Expand Up @@ -155,6 +182,7 @@ v1.4.0 (3Q23)

v1.3.1 (2Q23)
-------------

- Minor bug fixes

v1.3.0 (2Q23)
Expand All @@ -176,6 +204,7 @@ v1.3.0 (2Q23)

v1.2.4 (3Q23)
-------------

- Per-class saliency maps for M-RCNN
- Disable semantic segmentation soft prediction processing
- Update export and nncf hyperparameters
Expand Down
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,7 @@ max-returns = 10
"ANN001", # Skip annotation type hint in test codes
"ANN201", # Skip return type hint in test codes
"D", # Test skips missing docstring argument with magic (fixture) methods.
"ARG001", # Some arguments are passed for executing fixture
]
"src/otx/**/*.py" = [
"ERA001",
Expand Down
2 changes: 1 addition & 1 deletion src/otx/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Copyright (C) 2023 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

__version__ = "2.1.0rc0"
__version__ = "2.0.0rc0"

from otx.core.types import * # noqa: F403

Expand Down
29 changes: 2 additions & 27 deletions src/otx/algo/accelerators/xpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,12 @@
#
from __future__ import annotations

from typing import Any, Union
from typing import Any

import numpy as np
import torch
from lightning.pytorch.accelerators import AcceleratorRegistry
from lightning.pytorch.accelerators.accelerator import Accelerator
from mmcv.ops.nms import NMSop
from mmcv.ops.roi_align import RoIAlign
from mmengine.structures import instance_data

from otx.algo.detection.utils import monkey_patched_nms, monkey_patched_roi_align
from otx.utils.utils import is_xpu_available


Expand All @@ -30,7 +25,6 @@ def setup_device(self, device: torch.device) -> None:
raise RuntimeError(msg)

torch.xpu.set_device(device)
self.patch_packages_xpu()

@staticmethod
def parse_devices(devices: str | list | torch.device) -> list:
Expand Down Expand Up @@ -59,26 +53,7 @@ def get_device_stats(self, device: str | torch.device) -> dict[str, Any]:
return {}

def teardown(self) -> None:
"""Cleans-up XPU-related resources."""
self.revert_packages_xpu()

def patch_packages_xpu(self) -> None:
"""Patch packages when xpu is available."""
# patch instance_data from mmengie
long_type_tensor = Union[torch.LongTensor, torch.xpu.LongTensor]
bool_type_tensor = Union[torch.BoolTensor, torch.xpu.BoolTensor]
instance_data.IndexType = Union[str, slice, int, list, long_type_tensor, bool_type_tensor, np.ndarray]

# patch nms and roi_align
self._nms_op_forward = NMSop.forward
self._roi_align_forward = RoIAlign.forward
NMSop.forward = monkey_patched_nms
RoIAlign.forward = monkey_patched_roi_align

def revert_packages_xpu(self) -> None:
"""Revert packages when xpu is available."""
NMSop.forward = self._nms_op_forward
RoIAlign.forward = self._roi_align_forward
"""Clean up any state created by the accelerator."""


AcceleratorRegistry.register(
Expand Down
14 changes: 10 additions & 4 deletions src/otx/algo/callbacks/adaptive_train_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,17 @@ class AdaptiveTrainScheduling(Callback):
Defaults to -0.025.
"""

def __init__(self, max_interval: int = 5, decay: float = -0.025):
def __init__(
self,
max_interval: int = 5,
decay: float = -0.025,
min_earlystop_patience: int = 3,
min_lrschedule_patience: int = 2,
):
self.max_interval = max_interval
self.decay = decay
self.min_earlystop_interval = 3
self.min_lrschedule_patience = 2
self.min_earlystop_patience = min_earlystop_patience
self.min_lrschedule_patience = min_lrschedule_patience
self._saved_check_val_every_n_epoch: int | None = None
self._saved_log_every_n_steps: int | None = None
self._revert_lr_frequency: list = []
Expand Down Expand Up @@ -153,7 +159,7 @@ def _revert_func(callback: Callback, saved_patience: int) -> None:

for callback in callbacks:
if isinstance(callback, EarlyStopping):
adjusted_patience = max(int(callback.patience / adaptive_interval), self.min_earlystop_interval)
adjusted_patience = max(int(callback.patience / adaptive_interval), self.min_earlystop_patience)
msg = (
"The patience of early stopping will be changed due to the effect of adaptive interval: "
f"{callback.patience} --> {adjusted_patience}."
Expand Down
15 changes: 10 additions & 5 deletions src/otx/algo/classification/classifier/base_classifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ def predict(self, inputs: torch.Tensor, **kwargs) -> list[torch.Tensor]:
feats = self.extract_feat(inputs)
return self.head.predict(feats, **kwargs)

@torch.no_grad()
def _forward_explain(self, images: torch.Tensor) -> dict[str, torch.Tensor | list[torch.Tensor]]:
"""Generates explanations for the given images using the classifier.
Expand All @@ -186,8 +187,8 @@ def _forward_explain(self, images: torch.Tensor) -> dict[str, torch.Tensor | lis
Returns:
dict[str, torch.Tensor | list[torch.Tensor]]: A dictionary containing the following keys:
- "logits" (torch.Tensor): The output logits from the classifier.
- "preds" (torch.Tensor): The predicted class labels.
- "scores" (torch.Tensor): The softmax scores for each class.
- "preds" (torch.Tensor): The predicted class labels. Only included in non-tracing mode.
- "scores" (torch.Tensor): The softmax scores for each class. Only included in non-tracing mode.
- "saliency_map" (torch.Tensor): The saliency map generated by the explainer.
- "feature_vector" (torch.Tensor): The feature vector extracted from the backbone network.
"""
Expand All @@ -212,14 +213,18 @@ def _forward_explain(self, images: torch.Tensor) -> dict[str, torch.Tensor | lis
scores = pred_results.unbind(0)
preds = logits.argmax(-1, keepdim=True).unbind(0)

return {
outputs = {
"logits": logits,
"feature_vector": feature_vector,
"saliency_map": saliency_map,
"scores": scores,
"preds": preds,
}

if not torch.jit.is_tracing():
outputs["scores"] = scores
outputs["preds"] = preds

return outputs

@torch.no_grad()
def _head_forward_fn(self, x: torch.Tensor) -> torch.Tensor:
"""Performs model's neck and head forward."""
Expand Down
6 changes: 3 additions & 3 deletions src/otx/algo/classification/efficientnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -246,7 +246,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -392,7 +392,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down
6 changes: 3 additions & 3 deletions src/otx/algo/classification/efficientnet_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -241,7 +241,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -384,7 +384,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down
6 changes: 3 additions & 3 deletions src/otx/algo/classification/mobilenet_v3.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -257,7 +257,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down Expand Up @@ -403,7 +403,7 @@ def _exporter(self) -> OTXModelExporter:
resize_mode="standard",
pad_value=0,
swap_rgb=False,
via_onnx=True, # NOTE: This should be done via onnx
via_onnx=False,
onnx_export_configuration=None,
output_names=["logits", "feature_vector", "saliency_map"] if self.explain_mode else None,
)
Expand Down
Loading

0 comments on commit 26cc9b0

Please sign in to comment.