Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge back OTX2.2RC12 to OTX2.3 #4071

Merged
merged 76 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
d1bd1d5
update for releases 2.2.0rc0
yunchu Aug 20, 2024
c16f985
Fix Classification explain forward issue (#3867)
harimkang Aug 21, 2024
cba5120
Fix e2e code error (#3871)
chuneuny-emily Aug 21, 2024
b807c9d
Add documentation about configurable input size (#3870)
eunwoosh Aug 21, 2024
2835aba
Fix zero-shot e2e (#3876)
sungchul2 Aug 23, 2024
ccf2d50
Fix DeiT for multi-label classification (#3881)
harimkang Aug 23, 2024
e577b6a
Fix Semi-SL for ViT accuracy drop (#3883)
harimkang Aug 23, 2024
d1dd2b0
Update docs for 2.2 (#3884)
harimkang Aug 23, 2024
c17a923
Fix mean and scale for segmentation task (#3885)
kprokofi Aug 23, 2024
d72feeb
Update MAPI in 2.2 (#3889)
sovrasov Aug 26, 2024
00ed3a0
Improve Semi-SL for LiteHRNet (small-medium case) (#3891)
kprokofi Aug 26, 2024
2c6b4de
Improve h-cls for eff models (#3893)
Aug 26, 2024
0dc7a29
Fix maskrcnn swin nncf acc drop (#3900)
eugene123tw Aug 27, 2024
0d6799c
Add keypoint detection recipe for single object cases (#3903)
wonjuleee Aug 28, 2024
8115b52
Improve acc drop of efficientnetv2 for h-label cls (#3907)
Aug 29, 2024
4c8555e
Fix pretrained weight cached dir for timm (#3909)
harimkang Aug 29, 2024
52221e3
Fix keypoint detection single obj recipe (#3915)
wonjuleee Aug 30, 2024
9265c59
Fix cached dir for timm & hugging-face (#3914)
harimkang Aug 30, 2024
5170736
Fix wrong template id mapping for anomaly (#3916)
yunchu Aug 30, 2024
f611cc1
Update script to allow setting otx version using env. variable (#3913)
yunchu Aug 30, 2024
425a479
Fix Datamodule creation for OV in AutoConfigurator (#3920)
harimkang Sep 2, 2024
7f1c7da
Update tpp file for 2.2.0 (#3921)
yunchu Sep 2, 2024
51d1adf
Fix names for ignored scope [HOT-FIX, 2.2.0] (#3924)
kprokofi Sep 3, 2024
2bcf1b2
Fix classification rt_info (#3922)
sovrasov Sep 3, 2024
112b2b2
Update label info (#3925)
ashwinvaidya17 Sep 4, 2024
929132d
Fix binary classification metric task (#3928)
harimkang Sep 5, 2024
706f99b
Improve MaskRCNN SwinT NNCF (#3929)
eugene123tw Sep 5, 2024
53a7d9a
Fix get_item for Chained Tasks in Classification (#3931)
harimkang Sep 5, 2024
c3749e3
Correct Keyerror for h-label cls in label_groups for dm_label_categor…
Sep 5, 2024
98a9cac
Remove datumaro attribute id from tiling, add subset names (#3933)
eugene123tw Sep 6, 2024
d8e6454
Fix soft predictions for Semantic Segmentation (#3934)
kprokofi Sep 6, 2024
c2705df
Update STFPM config (#3935)
ashwinvaidya17 Sep 6, 2024
c2ccfc9
Add missing pretrained weights when creating a docker image (#3938)
harimkang Sep 6, 2024
8b747f9
Change default option 'full' to 'base' in otx install (#3937)
harimkang Sep 9, 2024
d43226e
Fix auto adapt batch size in Converter (#3939)
harimkang Sep 9, 2024
1d319cd
Fix hpo converter (#3940)
eunwoosh Sep 9, 2024
aaa2765
Fix tiling XAI out of range (#3943)
eugene123tw Sep 9, 2024
ac87b49
enable model export (#3952)
ashwinvaidya17 Sep 12, 2024
8f96f27
Move templates from OTX1.X to OTX2.X (#3951)
kprokofi Sep 12, 2024
0f87c86
Add missing tile recipes and various tile recipe changes (#3942)
eugene123tw Sep 12, 2024
c7efcbc
Support ImageFromBytes (#3948)
ashwinvaidya17 Sep 12, 2024
ecef545
Change categories mapping logic (#3946)
kprokofi Sep 13, 2024
b1ec8e7
Update for 2.2.0rc1 (#3956)
yunchu Sep 13, 2024
aa31dca
Include Geti arrow dataset subset names (#3962)
eugene123tw Sep 20, 2024
93f1a55
Include full image with anno in case there's no tile in tile dataset …
eugene123tw Sep 20, 2024
45f9a24
Add type checker in converter for callable functions (optimizer, sche…
harimkang Sep 20, 2024
51fcb73
Update for 2.2.0rc2 (#3969)
yunchu Sep 20, 2024
46efe84
Fix config converter for tiling (#3973)
eugene123tw Sep 23, 2024
45078bc
Update for 2.2.0rc3 (#3975)
yunchu Sep 24, 2024
758ea97
Change sematic segmentation to consider bbox only annotations. (#3996)
eunwoosh Oct 4, 2024
7744c89
Relieve memory usage criteria on batch size 2 during adaptive_bs (#4009)
eunwoosh Oct 10, 2024
7040faf
Remove background label from RT Info for segmentation task (#4011)
kprokofi Oct 11, 2024
81829a3
Fix num_trials calculation on dataset length less than num_class (#4014)
harimkang Oct 11, 2024
a663cc9
Fix out_features in HierarchicalCBAMClsHead (#4016)
harimkang Oct 11, 2024
bc673e7
Fix empty anno (#4010)
eugene123tw Oct 11, 2024
324454e
Update for release 2.2.0rc5 (#4015)
yunchu Oct 11, 2024
026b5f0
Prevent using too low confidence thresholds in detection (#4018)
sovrasov Oct 14, 2024
886c361
Update for release 2.2.0rc6 (#4027)
yunchu Oct 14, 2024
91d2df2
Update pre-merge workflow (#4032)
yunchu Oct 15, 2024
a3c9fc6
Update HPO interface (#4035)
eunwoosh Oct 15, 2024
76b5044
Enable keypoint detection training through config conversion (#4034)
wonjuleee Oct 15, 2024
93adf0d
Update for release 2.2.0rc7 (#4036)
yunchu Oct 15, 2024
08de045
Fix multilabel_accuracy of MixedHLabelAccuracy (#4042)
harimkang Oct 17, 2024
d6458e6
Update for release 2.2.0rc8 (#4043)
yunchu Oct 17, 2024
b817d1b
Fix wrong indices setting in HLabelInfo (#4044)
harimkang Oct 17, 2024
45906da
Add legacy template LiteHRNet_18 template (#4049)
kprokofi Oct 22, 2024
a837a1d
Model templates: rename model_status value 'DISCONTINUED' to 'OBSOLET…
leoll2 Oct 22, 2024
decfdbe
Enable export of feature vectors for semantic segmentation task (#4055)
kprokofi Oct 23, 2024
63f71fb
Upgrade MAPI in 2.2 (#4052)
sovrasov Oct 23, 2024
7b07e6b
Update MRCNN model export to include feature vector and saliency map …
harimkang Oct 23, 2024
d85f5da
Fix applying model's hparams when loading model from checkpoint (#4057)
sungchul2 Oct 23, 2024
fbf0f3e
Update anomaly transforms (#4059)
ashwinvaidya17 Oct 24, 2024
8bba44c
Bump onnx to 1.17.0 to omit CVE-2024-5187 (#4063)
yunchu Oct 24, 2024
a2d2c81
Fix incorrect all_groups order configuration in HLabelInfo (#4067)
harimkang Oct 25, 2024
49ce322
merge releases/2.3.0
kprokofi Oct 25, 2024
ecb3c01
fix conflicts
kprokofi Oct 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions .ci/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,9 @@
FROM nvidia/cuda:12.1.0-runtime-ubuntu20.04@sha256:c1869c30f46fff478a37ed58d9dace7e08519541274f03424d0b78bd35b2c73a AS python_base_cuda
LABEL maintainer="OpenVINO Training Extensions Development Team"

ARG HTTP_PROXY
ARG HTTPS_PROXY
ARG NO_PROXY
ARG uid
ARG gid

# Setup proxies
ENV http_proxy=$HTTP_PROXY
ENV https_proxy=$HTTPS_PROXY
ENV no_proxy=$NO_PROXY
ENV DEBIAN_FRONTEND="noninteractive"

# hadolint ignore=DL3008
Expand Down
3 changes: 0 additions & 3 deletions .ci/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ fi
TAG=$1

docker build -f ./Dockerfile \
--build-arg HTTP_PROXY="${http_proxy:?}" \
--build-arg HTTPS_PROXY="${https_proxy:?}" \
--build-arg NO_PROXY="${no_proxy:?}" \
--build-arg ACTIONS_RUNNER_VER="$ACTIONS_RUNNER_VER" \
--build-arg gid="$(id -g)" \
--build-arg uid="$UID" \
Expand Down
8 changes: 1 addition & 7 deletions .ci/docker/start-runner.sh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/bin/bash

GPU_ID="all"
VER_CUDA="11.7.1"
VER_CUDA="12.1.0"
TAG_RUNNER="latest"
ADDITIONAL_LABELS=""
MOUNT_PATH=""
Expand Down Expand Up @@ -149,9 +149,6 @@ if [ "$DEBUG_CONTAINER" = true ]; then
--name "$CONTAINER_NAME" \
-e NVIDIA_VISIBLE_DEVICES="$GPU_ID" \
${ENV_FLAGS} \
-e http_proxy=http://proxy-chain.intel.com:911 \
-e https_proxy=http://proxy-chain.intel.com:912 \
-e no_proxy=intel.com,.intel.com,localhost,127.0.0.0/8 \
${MOUNT_FLAGS} \
${CACHE_MOUNT_FLAGS} \
"$DOCKER_REG_ADDR"/ote/ci/cu"$VER_CUDA"/runner:"$TAG_RUNNER"; RET=$?
Expand All @@ -172,9 +169,6 @@ else
--name "$CONTAINER_NAME" \
-e NVIDIA_VISIBLE_DEVICES="$GPU_ID" \
${ENV_FLAGS} \
-e http_proxy=http://proxy-chain.intel.com:911 \
-e https_proxy=http://proxy-chain.intel.com:912 \
-e no_proxy=intel.com,.intel.com,localhost,127.0.0.0/8 \
${MOUNT_FLAGS} \
${CACHE_MOUNT_FLAGS} \
"$DOCKER_REG_ADDR"/ote/ci/cu"$VER_CUDA"/runner:"$TAG_RUNNER"; RET=$?
Expand Down
32 changes: 29 additions & 3 deletions .github/workflows/pre_merge.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,6 @@ jobs:
- task: "multi_cls_classification"
- task: "multi_label_classification"
- task: "hlabel_classification"
- task: "detection"
- task: "instance_segmentation"
- task: "semantic_segmentation"
- task: "visual_prompting"
- task: "zero_shot_visual_prompting"
- task: "anomaly_classification"
Expand All @@ -127,3 +124,32 @@ jobs:
rm /tmp/requirements.txt
- name: Run Integration Test
run: tox -vv -e integration-test-${{ matrix.task }}
Integration-Test-Large:
if: |
github.event.pull_request.draft == false &&
!(startsWith(github.event.pull_request.title, '[WIP]'))
runs-on: [self-hosted, linux, x64, dev, dmount]
needs: Unit-Test
strategy:
fail-fast: false
matrix:
include:
- task: "detection"
- task: "instance_segmentation"
- task: "semantic_segmentation"
name: Integration-Test-Large-${{ matrix.task }}-py310
steps:
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Install Python
uses: actions/setup-python@39cd14951b08e74b54015e9e001cdefcf80e669f # v5.1.1
with:
python-version: "3.10"
- name: Install tox
run: |
python -m pip install --require-hashes --no-deps -r .ci/requirements.txt
pip-compile --generate-hashes --output-file=/tmp/requirements.txt --extra=ci_tox pyproject.toml
python -m pip install --require-hashes --no-deps -r /tmp/requirements.txt
rm /tmp/requirements.txt
- name: Run Integration Test
run: tox -vv -e integration-test-${{ matrix.task }}
60 changes: 48 additions & 12 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,29 +40,29 @@ All notable changes to this project will be documented in this file.
### New features

- Add RT-DETR model for Object Detection
(https://github.com/openvinotoolkit/training_extensions/pull/3741)
(<https://github.com/openvinotoolkit/training_extensions/pull/3741>)
- Add Multi-Label & H-label Classification with torchvision models
(https://github.com/openvinotoolkit/training_extensions/pull/3697)
(<https://github.com/openvinotoolkit/training_extensions/pull/3697>)
- Add Hugging-Face Model Wrapper for Classification
(https://github.com/openvinotoolkit/training_extensions/pull/3710)
(<https://github.com/openvinotoolkit/training_extensions/pull/3710>)
- Add LoRA finetuning capability for ViT Architectures
(https://github.com/openvinotoolkit/training_extensions/pull/3729)
(<https://github.com/openvinotoolkit/training_extensions/pull/3729>)
- Add Hugging-Face Model Wrapper for Object Detection
(https://github.com/openvinotoolkit/training_extensions/pull/3747)
(<https://github.com/openvinotoolkit/training_extensions/pull/3747>)
- Add Hugging-Face Model Wrapper for Semantic Segmentation
(https://github.com/openvinotoolkit/training_extensions/pull/3749)
(<https://github.com/openvinotoolkit/training_extensions/pull/3749>)
- Enable torch.compile to work with classification
(https://github.com/openvinotoolkit/training_extensions/pull/3758)
(<https://github.com/openvinotoolkit/training_extensions/pull/3758>)
- Add `otx benchmark` subcommand
(https://github.com/openvinotoolkit/training_extensions/pull/3762)
(<https://github.com/openvinotoolkit/training_extensions/pull/3762>)
- Add RTMPose for Keypoint Detection Task
(https://github.com/openvinotoolkit/training_extensions/pull/3781)
(<https://github.com/openvinotoolkit/training_extensions/pull/3781>, <https://github.com/openvinotoolkit/training_extensions/pull/4034>)
- Add Semi-SL MeanTeacher algorithm for Semantic Segmentation
(https://github.com/openvinotoolkit/training_extensions/pull/3801)
(<https://github.com/openvinotoolkit/training_extensions/pull/3801>)
- Update head and h-label format for hierarchical label classification
(https://github.com/openvinotoolkit/training_extensions/pull/3810)
(<https://github.com/openvinotoolkit/training_extensions/pull/3810>)
- Support configurable input size
(https://github.com/openvinotoolkit/training_extensions/pull/3788)
(<https://github.com/openvinotoolkit/training_extensions/pull/3788>)

### Enhancements

Expand Down Expand Up @@ -90,9 +90,21 @@ All notable changes to this project will be documented in this file.
(<https://github.com/openvinotoolkit/training_extensions/pull/3968>)
- Change sematic segmentation to consider bbox only annotations
(<https://github.com/openvinotoolkit/training_extensions/pull/3996>)
- Relieve memory usage criteria on batch size 2 during adaptive batch size
(<https://github.com/openvinotoolkit/training_extensions/pull/4009>)
- Remove background label from RT Info for segmentation task
(<https://github.com/openvinotoolkit/training_extensions/pull/4011>)
- Prevent using too low confidence thresholds in detection
(<https://github.com/openvinotoolkit/training_extensions/pull/4018>)
- Update HPO interface
(<https://github.com/openvinotoolkit/training_extensions/pull/4035>)
- Bump onnx to 1.17.0 to omit CVE-2024-5187
(<https://github.com/openvinotoolkit/training_extensions/pull/4063>)

### Bug fixes

- Update anomaly base transforms to use square resizing
(<https://github.com/openvinotoolkit/training_extensions/pull/4059>)
- Fix Combined Dataloader & unlabeled warmup loss in Semi-SL
(<https://github.com/openvinotoolkit/training_extensions/pull/3723>)
- Revert #3579 to fix issues with replacing coco_instance with a different format in some dataset
Expand All @@ -105,6 +117,30 @@ All notable changes to this project will be documented in this file.
(<https://github.com/openvinotoolkit/training_extensions/pull/3946>)
- Fix config converter for tiling
(<https://github.com/openvinotoolkit/training_extensions/pull/3973>)
- Fix `BboxOverlaps2D` handling of empty ground-truth annotations in datasets.
(<https://github.com/openvinotoolkit/training_extensions/pull/4010>)
- Fix num_trials calculation on dataset length less than num_class
(<https://github.com/openvinotoolkit/training_extensions/pull/4014>)
- Fix out_features in HierarchicalCBAMClsHead
(<https://github.com/openvinotoolkit/training_extensions/pull/4016>)
- Fix multilabel_accuracy of MixedHLabelAccuracy
(<https://github.com/openvinotoolkit/training_extensions/pull/4042>)
- Fix wrong indices setting in HLabelInfo
(<https://github.com/openvinotoolkit/training_extensions/pull/4044>)
- Add legacy template LiteHRNet_18 template
(<https://github.com/openvinotoolkit/training_extensions/pull/4049>)
- Model templates: rename model_status value 'DISCONTINUED' to 'OBSOLETE'
(<https://github.com/openvinotoolkit/training_extensions/pull/4051>)
- Enable export of feature vectors for semantic segmentation task
(<https://github.com/openvinotoolkit/training_extensions/pull/4055>)
- Update MRCNN model export to include feature vector and saliency map
(<https://github.com/openvinotoolkit/training_extensions/pull/4056>)
- Upgrade MAPI in 2.2
(<https://github.com/openvinotoolkit/training_extensions/pull/4052>)
- Fix applying model's hparams when loading model from checkpoint
(<https://github.com/openvinotoolkit/training_extensions/pull/4057>)
- Fix incorrect all_groups order configuration in HLabelInfo
(<https://github.com/openvinotoolkit/training_extensions/pull/4067>)

## \[v2.1.0\]

Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ In addition to the examples above, please refer to the documentation for tutoria
- Include full image with anno in case there's no tile in tile dataset
- Add type checker in converter for callable functions (optimizer, scheduler)
- Change sematic segmentation to consider bbox only annotations
- Relieve memory usage criteria on batch size 2 during adaptive batch size
- Remove background label from RT Info for segmentation task
- Prevent using too low confidence thresholds in detection

### Bug fixes

Expand All @@ -206,6 +209,10 @@ In addition to the examples above, please refer to the documentation for tutoria
- Add missing tile recipes and various tile recipe changes
- Change categories mapping logic
- Fix config converter for tiling
- Fix num_trials calculation on dataset length less than num_class
- Fix out_features in HierarchicalCBAMClsHead
- Fix multilabel_accuracy of MixedHLabelAccuracy
- Fix wrong indices setting in HLabelInfo

### Known issues

Expand Down
9 changes: 8 additions & 1 deletion docs/source/guide/release_notes/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Releases
.. toctree::
:maxdepth: 1

v2.2.0 (2024.09)
v2.2.0 (2024.10)
----------------

New features
Expand Down Expand Up @@ -38,6 +38,9 @@ Enhancements
- Include full image with anno in case there's no tile in tile dataset
- Add type checker in converter for callable functions (optimizer, scheduler)
- Change sematic segmentation to consider bbox only annotations
- Relieve memory usage criteria on batch size 2 during adaptive batch size
- Remove background label from RT Info for segmentation task
- Prevent using too low confidence thresholds in detection

Bug fixes
^^^^^^^^^
Expand All @@ -48,6 +51,10 @@ Bug fixes
- Add missing tile recipes and various tile recipe changes
- Change categories mapping logic
- Fix config converter for tiling
- Fix num_trials calculation on dataset length less than num_class
- Fix out_features in HierarchicalCBAMClsHead
- Fix multilabel_accuracy of MixedHLabelAccuracy
- Fix wrong indices setting in HLabelInfo

v2.1.0 (2024.07)
----------------
Expand Down
6 changes: 3 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ xpu = [
"timm==1.0.3",
"openvino==2024.4",
"openvino-dev==2024.4",
"openvino-model-api==0.2.4",
"onnx==1.16.2",
"openvino-model-api==0.2.5",
"onnx==1.17.0",
"onnxconverter-common==1.14.0",
"nncf==2.13.0",
"anomalib[core]==1.1.0",
Expand All @@ -96,7 +96,7 @@ base = [
"openvino==2024.4",
"openvino-dev==2024.4",
"openvino-model-api==0.2.4",
"onnx==1.16.2",
"onnx==1.17.0",
"onnxconverter-common==1.14.0",
"nncf==2.13.0",
"anomalib[core]==1.1.0",
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/classification/heads/hlabel_cls_head.py
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,7 @@ def __init__(
self.fc_superclass = nn.Linear(in_channels * self.step_size[0] * self.step_size[1], num_multiclass_heads)
self.attention_fc = nn.Linear(num_multiclass_heads, in_channels * self.step_size[0] * self.step_size[1])
self.cbam = CBAM(in_channels)
self.fc_subclass = nn.Linear(in_channels * self.step_size[0] * self.step_size[1], num_single_label_classes)
self.fc_subclass = nn.Linear(in_channels * self.step_size[0] * self.step_size[1], num_classes)

self._init_layers()

Expand Down
19 changes: 17 additions & 2 deletions src/otx/algo/common/utils/bbox_overlaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

from __future__ import annotations

import warnings

import torch
from torch import Tensor

Expand Down Expand Up @@ -142,15 +144,28 @@
>>> assert tuple(bbox_overlaps(nonempty, empty).shape) == (1, 0)
>>> assert tuple(bbox_overlaps(empty, empty).shape) == (0, 0)
"""
if not (bboxes1.size(-1) == 4 or bboxes1.size(0) == 0):
msg = "bboxes1 must have a last dimension of size 4 or be an empty tensor."
raise ValueError(msg)

Check warning on line 149 in src/otx/algo/common/utils/bbox_overlaps.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/common/utils/bbox_overlaps.py#L148-L149

Added lines #L148 - L149 were not covered by tests

if not (bboxes2.size(-1) == 4 or bboxes2.size(0) == 0):
msg = "bboxes2 must have a last dimension of size 4 or be an empty tensor."
raise ValueError(msg)

Check warning on line 153 in src/otx/algo/common/utils/bbox_overlaps.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/common/utils/bbox_overlaps.py#L152-L153

Added lines #L152 - L153 were not covered by tests

if bboxes1.shape[:-2] != bboxes2.shape[:-2]:
msg = "The batch dimension of bboxes must be the same."
raise ValueError(msg)

batch_shape = bboxes1.shape[:-2]

rows = bboxes1.size(-2)
cols = bboxes2.size(-2)

if rows * cols == 0:
warnings.warn("No bboxes are provided! Returning empty boxes!", stacklevel=2)
if is_aligned:
return bboxes1.new((*batch_shape, rows))
return bboxes1.new((*batch_shape, rows, cols))
return bboxes1.new(batch_shape + (rows,)) # noqa: RUF005
return bboxes1.new(batch_shape + (rows, cols)) # noqa: RUF005

area1 = (bboxes1[..., 2] - bboxes1[..., 0]) * (bboxes1[..., 3] - bboxes1[..., 1])
area2 = (bboxes2[..., 2] - bboxes2[..., 0]) * (bboxes2[..., 3] - bboxes2[..., 1])
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/instance_segmentation/maskrcnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ def _exporter(self) -> OTXModelExporter:
"opset_version": 11,
"autograd_inlining": False,
},
output_names=["bboxes", "labels", "masks"],
output_names=["bboxes", "labels", "masks", "feature_vector", "saliency_map"] if self.explain_mode else None,
)

def load_from_otx_v1_ckpt(self, state_dict: dict, add_prefix: str = "model.") -> dict:
Expand Down
1 change: 1 addition & 0 deletions src/otx/algo/instance_segmentation/rtmdet_inst.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ def _exporter(self) -> OTXModelExporter:
"opset_version": 11,
"autograd_inlining": False,
},
# TODO(Eugene): Add XAI support for RTMDetInst
output_names=["bboxes", "labels", "masks", "feature_vector", "saliency_map"] if self.explain_mode else None,
)

Expand Down
35 changes: 30 additions & 5 deletions src/otx/algo/instance_segmentation/segmentors/two_stage.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,19 +226,44 @@
self,
batch_inputs: torch.Tensor,
batch_img_metas: list[dict],
) -> tuple[torch.Tensor, ...]:
"""Export for two stage detectors."""
x = self.extract_feat(batch_inputs)
explain_mode: bool,
) -> tuple[torch.Tensor, torch.Tensor, torch.Tensor] | dict:
"""Export the model for ONNX/OpenVINO.

Args:
batch_inputs (torch.Tensor): image tensor with shape (N, C, H, W).
batch_img_metas (list[dict]): image information.
explain_mode (bool): whether to return feature vector.

Returns:
tuple[torch.Tensor, torch.Tensor, torch.Tensor] | dict:
- bboxes (torch.Tensor): bounding boxes.
- labels (torch.Tensor): labels.
- masks (torch.Tensor): masks.
- feature_vector (torch.Tensor, optional): feature vector.
- saliency_map (torch.Tensor, optional): saliency map.
"""
x = self.extract_feat(batch_inputs)
rpn_results_list = self.rpn_head.export(
x,
batch_img_metas,
rescale=False,
)

return self.roi_head.export(
bboxes, labels, masks = self.roi_head.export(
x,
rpn_results_list,
batch_img_metas,
rescale=False,
)

if explain_mode:
feature_vector = self.feature_vector_fn(x)
return {

Check warning on line 261 in src/otx/algo/instance_segmentation/segmentors/two_stage.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/instance_segmentation/segmentors/two_stage.py#L260-L261

Added lines #L260 - L261 were not covered by tests
"bboxes": bboxes,
"labels": labels,
"masks": masks,
"feature_vector": feature_vector,
# create dummy tensor as model API supports saliency_map
"saliency_map": torch.zeros(1),
}
return bboxes, labels, masks
Loading
Loading