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 2.2 #4098

Merged
merged 106 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
106 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)
sooahleex 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)
sooahleex 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…
sooahleex 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
7bb36ef
Fix wrong model name in converter & template (#4082)
harimkang Oct 29, 2024
2bdc356
RTMDet Inst Seg Explain Mode for 2.2 (#4083)
eugene123tw Oct 29, 2024
c2614a5
Fix rtdetr recipes (#4079)
sungchul2 Oct 29, 2024
dc882bf
Enable adaptive_bs with Efficientnet-V2-L model template (#4085)
harimkang Oct 30, 2024
15746ea
Add Keypoint Detection legacy template (#4094)
kprokofi Nov 5, 2024
5aabd21
merge develop
kprokofi Nov 5, 2024
721a9d2
fix template
kprokofi Nov 5, 2024
bb15adc
Revert the old workaround for detection confidence threshold (#4096)
sovrasov Nov 6, 2024
0556ea6
OTX RC 2.2 version up (#4099)
sovrasov Nov 6, 2024
e46d804
merge develop
kprokofi Nov 6, 2024
349b599
fix linter
kprokofi Nov 6, 2024
88ab4b8
Add dummy XAI to RTDETR (export mode) & disable strong aug (#4106)
eugene123tw Nov 8, 2024
844fc2e
Fix task chain for Det -> Cls / Seg (#4105)
kprokofi Nov 8, 2024
74549b0
update rc14
kprokofi Nov 8, 2024
b3515cf
minor change to CHANGELOG
kprokofi Nov 8, 2024
24a21cf
Merge branch 'develop' into kp/merge_back_2.2
kprokofi Nov 8, 2024
4639907
fix linter
kprokofi Nov 8, 2024
21560aa
Merge branch 'develop' into kp/merge_back_2.2
kprokofi Nov 11, 2024
6a56b66
fix diffusion
kprokofi Nov 11, 2024
71935f0
fix tiling
kprokofi Nov 11, 2024
9667035
Disable tiling classifier toggle in configurable parameters (#4107)
sovrasov Nov 11, 2024
87c4ed2
update releses/2.2
kprokofi Nov 11, 2024
81f2db8
fix RTDETR
kprokofi Nov 11, 2024
88fa4a7
fix test with augs
kprokofi Nov 12, 2024
a01c507
switch off the IS for test_augs
kprokofi Nov 13, 2024
c945e44
remove FilterAnnotations for RTMdet
kprokofi Nov 13, 2024
f3ce785
Update keypoint detection template (#4114)
kprokofi Nov 14, 2024
5bc8332
quick fix for rtmdet
kprokofi Nov 14, 2024
6cbb5f2
minor update
kprokofi Nov 14, 2024
b8f5e09
Merge branch 'kp/fix_changelog' into kp/merge_back_2.2
kprokofi Nov 14, 2024
708757b
minor fix
kprokofi Nov 14, 2024
2c99adb
Merge branch 'develop' into kp/merge_back_2.2
kprokofi Nov 14, 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
20 changes: 18 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ All notable changes to this project will be documented in this file.
(<https://github.com/openvinotoolkit/training_extensions/pull/3788>)
- Add diffusion task
(<https://github.com/openvinotoolkit/training_extensions/pull/3875>)
- Revert the old workaround for detection confidence threshold
(<https://github.com/openvinotoolkit/training_extensions/pull/4096>)
- Add Keypoint Detection legacy template
(<https://github.com/openvinotoolkit/training_extensions/pull/4094>)

### Enhancements

Expand Down Expand Up @@ -125,6 +129,8 @@ All notable changes to this project will be documented in this file.
(<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>)
- Enable export of the feature vectors for semantic segmentation task
(<https://github.com/openvinotoolkit/training_extensions/pull/4055>)
- Prevent using too low confidence thresholds in detection
(<https://github.com/openvinotoolkit/training_extensions/pull/4018>)
- Update HPO interface
Expand Down Expand Up @@ -162,8 +168,6 @@ All notable changes to this project will be documented in this file.
(<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
Expand All @@ -172,6 +176,18 @@ All notable changes to this project will be documented in this file.
(<https://github.com/openvinotoolkit/training_extensions/pull/4057>)
- Fix incorrect all_groups order configuration in HLabelInfo
(<https://github.com/openvinotoolkit/training_extensions/pull/4067>)
- Fix RTDETR recipes
(<https://github.com/openvinotoolkit/training_extensions/pull/4079>)
- Fix wrong model name in converter & template
(<https://github.com/openvinotoolkit/training_extensions/pull/4082>)
- Fix RTMDet Inst Explain Mode
(<https://github.com/openvinotoolkit/training_extensions/pull/4083>)
- Fix RTDETR Explain Mode
(<https://github.com/openvinotoolkit/training_extensions/pull/4106>)
- Fix classification and semantic segmentation tasks, when ROI provided for images
(<https://github.com/openvinotoolkit/training_extensions/pull/4105>)
- Disable tiling classifier toggle in configurable parameters
(<https://github.com/openvinotoolkit/training_extensions/pull/4107>)

## \[v2.1.0\]

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ base = [
"timm==1.0.3",
"openvino==2024.4",
"openvino-dev==2024.4",
"openvino-model-api==0.2.4",
"openvino-model-api==0.2.5",
"onnx==1.17.0",
"onnxconverter-common==1.14.0",
"nncf==2.13.0",
Expand Down
17 changes: 12 additions & 5 deletions src/otx/algo/detection/detectors/detection_transformer.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from __future__ import annotations

import warnings
from typing import Any

import numpy as np
Expand Down Expand Up @@ -95,16 +96,22 @@
explain_mode: bool = False,
) -> dict[str, Any] | tuple[list[Any], list[Any], list[Any]]:
"""Exports the model."""
if explain_mode:
msg = "Explain mode is not supported for DETR models yet."
raise NotImplementedError(msg)

return self.postprocess(
results = self.postprocess(
self._forward_features(batch_inputs),
[meta["img_shape"] for meta in batch_img_metas],
deploy_mode=True,
)

if explain_mode:
# TODO(Eugene): Implement explain mode for DETR model.
warnings.warn("Explain mode is not supported for DETR model. Return dummy values.", stacklevel=2)
xai_output = {

Check warning on line 108 in src/otx/algo/detection/detectors/detection_transformer.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/detection/detectors/detection_transformer.py#L107-L108

Added lines #L107 - L108 were not covered by tests
"feature_vector": torch.zeros(1, 1),
"saliency_map": torch.zeros(1),
}
results.update(xai_output) # type: ignore[union-attr]

Check warning on line 112 in src/otx/algo/detection/detectors/detection_transformer.py

View check run for this annotation

Codecov / codecov/patch

src/otx/algo/detection/detectors/detection_transformer.py#L112

Added line #L112 was not covered by tests
return results

def postprocess(
self,
outputs: dict[str, Tensor],
Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/utils/xai_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ def _get_image_data_name(
subset = datamodule.subsets[subset_name]
item = subset.dm_subset[img_id]
img = item.media_as(Image)
img_data, _ = subset._get_img_data_and_shape(img) # noqa: SLF001
img_data, _, _ = subset._get_img_data_and_shape(img) # noqa: SLF001
image_save_name = "".join([char if char.isalnum() else "_" for char in item.id])
return img_data, image_save_name

Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/anomaly.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def _get_item_impl(
datumaro_item = self.dm_subset[index]
img = datumaro_item.media_as(Image)
# returns image in RGB format if self.image_color_channel is RGB
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

label = self._get_label(datumaro_item)

Expand Down
59 changes: 48 additions & 11 deletions src/otx/core/data/dataset/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from abc import abstractmethod
from collections.abc import Iterable
from contextlib import contextmanager
from typing import TYPE_CHECKING, Callable, Generic, Iterator, List, Union
from typing import TYPE_CHECKING, Any, Callable, Generic, Iterator, List, Union

import cv2
import numpy as np
Expand Down Expand Up @@ -92,6 +92,7 @@
self.image_color_channel = image_color_channel
self.stack_images = stack_images
self.to_tv_image = to_tv_image

if self.dm_subset.categories():
self.label_info = LabelInfo.from_dm_label_groups(self.dm_subset.categories()[AnnotationType.label])
else:
Expand Down Expand Up @@ -141,11 +142,30 @@
msg = f"Reach the maximum refetch number ({self.max_refetch})"
raise RuntimeError(msg)

def _get_img_data_and_shape(self, img: Image) -> tuple[np.ndarray, tuple[int, int]]:
key = img.path if isinstance(img, ImageFromFile) else id(img)
def _get_img_data_and_shape(
self,
img: Image,
roi: dict[str, Any] | None = None,
) -> tuple[np.ndarray, tuple[int, int], dict[str, Any] | None]:
"""Get image data and shape.

This method is used to get image data and shape from Datumaro image object.
If ROI is provided, the image data is extracted from the ROI.

Args:
img (Image): Image object from Datumaro.
roi (dict[str, Any] | None, Optional): Region of interest.
Represented by dict with coordinates and some meta information.

if (img_data := self.mem_cache_handler.get(key=key)[0]) is not None:
return img_data, img_data.shape[:2]
Returns:
The image data, shape, and ROI meta information
"""
key = img.path if isinstance(img, ImageFromFile) else id(img)
roi_meta = None
# check if the image is already in the cache
img_data, roi_meta = self.mem_cache_handler.get(key=key)
if img_data is not None:
return img_data, img_data.shape[:2], roi_meta

with image_decode_context():
img_data = (
Expand All @@ -158,11 +178,28 @@
msg = "Cannot get image data"
raise RuntimeError(msg)

img_data = self._cache_img(key=key, img_data=img_data.astype(np.uint8))
if roi and isinstance(roi, dict):
# extract ROI from image
shape = roi["shape"]
h, w = img_data.shape[:2]
x1, y1, x2, y2 = (
int(np.clip(np.trunc(shape["x1"] * w), 0, w)),
int(np.clip(np.trunc(shape["y1"] * h), 0, h)),
int(np.clip(np.ceil(shape["x2"] * w), 0, w)),
int(np.clip(np.ceil(shape["y2"] * h), 0, h)),
)
if (x2 - x1) * (y2 - y1) <= 0:
msg = f"ROI has zero or negative area. ROI coordinates: {x1}, {y1}, {x2}, {y2}"
raise ValueError(msg)

Check warning on line 193 in src/otx/core/data/dataset/base.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/base.py#L192-L193

Added lines #L192 - L193 were not covered by tests

img_data = img_data[y1:y2, x1:x2]
roi_meta = {"x1": x1, "y1": y1, "x2": x2, "y2": y2, "orig_image_shape": (h, w)}

img_data = self._cache_img(key=key, img_data=img_data.astype(np.uint8), meta=roi_meta)

return img_data, img_data.shape[:2]
return img_data, img_data.shape[:2], roi_meta

def _cache_img(self, key: str | int, img_data: np.ndarray) -> np.ndarray:
def _cache_img(self, key: str | int, img_data: np.ndarray, meta: dict[str, Any] | None = None) -> np.ndarray:
"""Cache an image after resizing.

If there is available space in the memory pool, the input image is cached.
Expand All @@ -182,14 +219,14 @@
return img_data

if self.mem_cache_img_max_size is None:
self.mem_cache_handler.put(key=key, data=img_data, meta=None)
self.mem_cache_handler.put(key=key, data=img_data, meta=meta)
return img_data

height, width = img_data.shape[:2]
max_height, max_width = self.mem_cache_img_max_size

if height <= max_height and width <= max_width:
self.mem_cache_handler.put(key=key, data=img_data, meta=None)
self.mem_cache_handler.put(key=key, data=img_data, meta=meta)

Check warning on line 229 in src/otx/core/data/dataset/base.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/base.py#L229

Added line #L229 was not covered by tests
return img_data

# Preserve the image size ratio and fit to max_height or max_width
Expand All @@ -206,7 +243,7 @@
self.mem_cache_handler.put(
key=key,
data=resized_img,
meta=None,
meta=meta,
)
return resized_img

Expand Down
28 changes: 14 additions & 14 deletions src/otx/core/data/dataset/classification.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,18 @@
def _get_item_impl(self, index: int) -> MulticlassClsDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(Image)
img_data, img_shape = self._get_img_data_and_shape(img)
roi = item.attributes.get("roi", None)
img_data, img_shape, _ = self._get_img_data_and_shape(img, roi)
if roi:
# extract labels from ROI
labels_ids = [

Check warning on line 39 in src/otx/core/data/dataset/classification.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/classification.py#L39

Added line #L39 was not covered by tests
label["label"]["_id"] for label in roi["labels"] if label["label"]["domain"] == "CLASSIFICATION"
]
label_anns = [self.label_info.label_names.index(label_id) for label_id in labels_ids]

Check warning on line 42 in src/otx/core/data/dataset/classification.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/classification.py#L42

Added line #L42 was not covered by tests
else:
# extract labels from annotations
label_anns = [ann.label for ann in item.annotations if isinstance(ann, Label)]

label_anns = []
for ann in item.annotations:
if isinstance(ann, Label):
label_anns.append(ann)
else:
# If the annotation is not Label, it should be converted to Label.
# For Chained Task: Detection (Bbox) -> Classification (Label)
label = Label(label=ann.label)
if label not in label_anns:
label_anns.append(label)
if len(label_anns) > 1:
msg = f"Multi-class Classification can't use the multi-label, currently len(labels) = {len(label_anns)}"
raise ValueError(msg)
Expand All @@ -56,7 +56,7 @@
ori_shape=img_shape,
image_color_channel=self.image_color_channel,
),
labels=torch.as_tensor([ann.label for ann in label_anns]),
labels=torch.as_tensor(label_anns),
)

return self._apply_transforms(entity)
Expand All @@ -78,7 +78,7 @@
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = [] # This should be assigned form item
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

label_anns = []
for ann in item.annotations:
Expand Down Expand Up @@ -195,7 +195,7 @@
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = [] # This should be assigned form item
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

label_anns = []
for ann in item.annotations:
Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def _get_item_impl(self, index: int) -> DetDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = [] # This should be assigned form item
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

bbox_anns = [ann for ann in item.annotations if isinstance(ann, Bbox)]

Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/diffusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
item = self.dm_subset[idx]
caption = item.annotations[0].caption
img = item.media_as(Image)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

Check warning on line 25 in src/otx/core/data/dataset/diffusion.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/diffusion.py#L25

Added line #L25 was not covered by tests
entity = DiffusionDataEntity(
image=img_data,
img_info=ImageInfo(
Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/instance_segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def _get_item_impl(self, index: int) -> InstanceSegDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = []
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

gt_bboxes, gt_labels, gt_masks, gt_polygons = [], [], [], []

Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/keypoint_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def _get_item_impl(self, index: int) -> KeypointDetDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = [] # This should be assigned form item
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

bbox_anns = [ann for ann in item.annotations if isinstance(ann, Bbox)]
bboxes = (
Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/dataset/object_detection_3d.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def __init__(
def _get_item_impl(self, index: int) -> Det3DDataEntity | None:
entity = self.dm_subset[index]
image = entity.media_as(Image)
image, ori_img_shape = self._get_img_data_and_shape(image)
image, ori_img_shape, _ = self._get_img_data_and_shape(image)
calib = self.get_calib_from_file(entity.attributes["calib_path"])
annotations_copy = deepcopy(entity.annotations)
datumaro_kitti_format = [obj.attributes for obj in annotations_copy]
Expand Down
9 changes: 7 additions & 2 deletions src/otx/core/data/dataset/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,14 @@
item = self.dm_subset[index]
img = item.media_as(Image)
ignored_labels: list[int] = []
img_data, img_shape = self._get_img_data_and_shape(img)
roi = item.attributes.get("roi", None)
img_data, img_shape, roi_meta = self._get_img_data_and_shape(img, roi)
if item.annotations:
extracted_mask = _extract_class_mask(item=item, img_shape=img_shape, ignore_index=self.ignore_index)
ori_shape = roi_meta["orig_image_shape"] if roi_meta else img_shape
extracted_mask = _extract_class_mask(item=item, img_shape=ori_shape, ignore_index=self.ignore_index)
if roi_meta:
extracted_mask = extracted_mask[roi_meta["y1"] : roi_meta["y2"], roi_meta["x1"] : roi_meta["x2"]]

Check warning on line 212 in src/otx/core/data/dataset/segmentation.py

View check run for this annotation

Codecov / codecov/patch

src/otx/core/data/dataset/segmentation.py#L212

Added line #L212 was not covered by tests

masks = tv_tensors.Mask(extracted_mask[None])
else:
# semi-supervised learning, unlabeled dataset
Expand Down
6 changes: 3 additions & 3 deletions src/otx/core/data/dataset/tile.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def _get_item_impl(self, index: int) -> TileDetDataEntity: # type: ignore[overr
"""
item = self.dm_subset[index]
img = item.media_as(Image)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

bbox_anns = [ann for ann in item.annotations if isinstance(ann, Bbox)]

Expand Down Expand Up @@ -505,7 +505,7 @@ def _get_item_impl(self, index: int) -> TileInstSegDataEntity: # type: ignore[o
"""
item = self.dm_subset[index]
img = item.media_as(Image)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

gt_bboxes, gt_labels, gt_masks, gt_polygons = [], [], [], []

Expand Down Expand Up @@ -607,7 +607,7 @@ def _get_item_impl(self, index: int) -> TileSegDataEntity: # type: ignore[overr
"""
item = self.dm_subset[index]
img = item.media_as(Image)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

extracted_mask = _extract_class_mask(item=item, img_shape=img_shape, ignore_index=self.ignore_index)
masks = tv_tensors.Mask(extracted_mask[None])
Expand Down
4 changes: 2 additions & 2 deletions src/otx/core/data/dataset/visual_prompting.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def __init__(
def _get_item_impl(self, index: int) -> VisualPromptingDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(dmImage)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

gt_bboxes, gt_points = [], []
gt_masks = defaultdict(list)
Expand Down Expand Up @@ -229,7 +229,7 @@ def __init__(
def _get_item_impl(self, index: int) -> ZeroShotVisualPromptingDataEntity | None:
item = self.dm_subset[index]
img = item.media_as(dmImage)
img_data, img_shape = self._get_img_data_and_shape(img)
img_data, img_shape, _ = self._get_img_data_and_shape(img)

prompts: list[ZeroShotPromptType] = []
gt_masks: list[tvMask] = []
Expand Down
1 change: 1 addition & 0 deletions src/otx/core/data/transform_libs/torchvision.py
Original file line number Diff line number Diff line change
Expand Up @@ -2650,6 +2650,7 @@ def forward(self, *_inputs: T_OTXDataEntity) -> T_OTXDataEntity | None:
if not keep.any() and self.keep_empty:
return self.convert(inputs)

keep = list(keep)
keys = ("bboxes", "labels", "masks", "polygons")
for key in keys:
if hasattr(inputs, key):
Expand Down
Loading
Loading