Skip to content

Commit e443fff

Browse files
Cleanup
Signed-off-by: Albert van Houten <albert.van.houten@intel.com>
1 parent 6ceeb48 commit e443fff

File tree

5 files changed

+6
-34
lines changed

5 files changed

+6
-34
lines changed

library/src/otx/backend/native/models/detection/ssd.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
from typing import TYPE_CHECKING, Any, ClassVar, Literal
1616

1717
import numpy as np
18-
from datumaro.experimental.dataset import Dataset as DmDataset
1918

2019
from otx.backend.native.exporter.base import OTXModelExporter
2120
from otx.backend.native.exporter.native import OTXNativeModelExporter
@@ -29,7 +28,6 @@
2928
from otx.backend.native.models.detection.utils.prior_generators import SSDAnchorGeneratorClustered
3029
from otx.backend.native.models.utils.utils import load_checkpoint
3130
from otx.config.data import TileConfig
32-
from otx.data.entity.sample import DetectionSample
3331
from otx.metrics.fmeasure import MeanAveragePrecisionFMeasureCallable
3432

3533
if TYPE_CHECKING:
@@ -245,19 +243,7 @@ def _get_sizes_from_dataset_entity(dataset: OTXDataset, target_wh: list[int]) ->
245243
list[tuple[int, int]]: tuples with width and height of each instance
246244
"""
247245
wh_stats = np.empty((0, 2), dtype=np.float32)
248-
if not isinstance(dataset.dm_subset, DmDataset):
249-
exc_str = "The variable dataset.dm_subset must be an instance of DmDataset"
250-
raise TypeError(exc_str)
251-
252246
for item in dataset.dm_subset:
253-
if not isinstance(item, DetectionSample):
254-
exc_str = "The variable item must be an instance of DetectionSample"
255-
raise TypeError(exc_str)
256-
257-
if item.img_info is None:
258-
exc_str = "The image info must not be None"
259-
raise RuntimeError(exc_str)
260-
261247
height, width = item.img_info.img_shape
262248
x1 = item.bboxes[:, 0]
263249
y1 = item.bboxes[:, 1]

library/src/otx/data/entity/tile.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from .base import ImageInfo
2020

2121
if TYPE_CHECKING:
22-
from datumaro import Polygon
22+
import numpy as np
2323
from datumaro.experimental.fields import TileInfo
2424
from torch import LongTensor
2525

@@ -162,13 +162,13 @@ class TileInstSegDataEntity(TileDataEntity):
162162
ori_bboxes (tv_tensors.BoundingBoxes): The bounding boxes of the original image.
163163
ori_labels (LongTensor): The labels of the original image.
164164
ori_masks (tv_tensors.Mask): The masks of the original image.
165-
ori_polygons (list[Polygon]): The polygons of the original image.
165+
ori_polygons (list[np.ndarray]): The polygons of the original image as arrays shaped (K, 2).
166166
"""
167167

168168
ori_bboxes: tv_tensors.BoundingBoxes
169169
ori_labels: LongTensor
170170
ori_masks: tv_tensors.Mask
171-
ori_polygons: list[Polygon]
171+
ori_polygons: list[np.ndarray]
172172

173173
@property
174174
def task(self) -> OTXTaskType:
@@ -184,13 +184,13 @@ class TileBatchInstSegDataEntity(OTXTileBatchDataEntity):
184184
bboxes (list[tv_tensors.BoundingBoxes]): The bounding boxes of the original image.
185185
labels (list[LongTensor]): The labels of the original image.
186186
masks (list[tv_tensors.Mask]): The masks of the original image.
187-
polygons (list[list[Polygon]]): The polygons of the original image.
187+
polygons (list[list[np.ndarray]]): The polygons of the original image as arrays shaped (K, 2).
188188
"""
189189

190190
bboxes: list[tv_tensors.BoundingBoxes]
191191
labels: list[LongTensor]
192192
masks: list[tv_tensors.Mask]
193-
polygons: list[list[Polygon]]
193+
polygons: list[list[np.ndarray]]
194194

195195
def unbind(self) -> list[tuple[TileAttrDictList, OTXDataBatch]]:
196196
"""Unbind batch data entity for instance segmentation task."""

library/src/otx/data/factory.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,8 @@
77

88
from typing import TYPE_CHECKING
99

10-
from datumaro.components.annotation import AnnotationType
11-
from datumaro.experimental.categories import LabelCategories
1210
from datumaro.experimental.legacy import convert_from_legacy
1311

14-
from otx import LabelInfo, NullLabelInfo
1512
from otx.types.task import OTXTaskType
1613
from otx.types.transformer_libs import TransformLibType
1714

@@ -115,13 +112,3 @@ def create(
115112
return OTXKeypointDetectionDataset(**common_kwargs)
116113

117114
raise NotImplementedError(task)
118-
119-
@staticmethod
120-
def _get_label_categories(dm_subset: DmDataset, data_format: str) -> LabelCategories:
121-
if dm_subset.categories() and data_format == "arrow":
122-
label_info = LabelInfo.from_dm_label_groups_arrow(dm_subset.categories()[AnnotationType.label])
123-
elif dm_subset.categories():
124-
label_info = LabelInfo.from_dm_label_groups(dm_subset.categories()[AnnotationType.label])
125-
else:
126-
label_info = NullLabelInfo()
127-
return LabelCategories(labels=label_info.label_names)

library/src/otx/data/transform_libs/torchvision.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1429,7 +1429,7 @@ def _transform_polygons(
14291429
filtered_polygons = (
14301430
[p for p, keep in zip(inputs.polygons, valid_index) if keep] if valid_index is not None else inputs.polygons
14311431
)
1432-
if len(filtered_polygons) > 0:
1432+
if filtered_polygons:
14331433
inputs.polygons = project_polygons(filtered_polygons, warp_matrix, output_shape)
14341434

14351435
def _recompute_bboxes(self, inputs: OTXDataItem, output_shape: tuple[int, int]) -> None:

library/tests/unit/tools/test_converter.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ def test_classification_augs(self, tmp_path):
112112
assert engine.datamodule.train_dataloader().dataset.transforms is not None
113113
assert len(engine.datamodule.train_dataloader().dataset.transforms.transforms) == 9
114114

115-
@pytest.mark.xfail(reason="Tiling not yet implemented with new dataset")
116115
def test_detection_augs(self, tmp_path):
117116
supported_augs_list_for_configuration = [
118117
"otx.data.transform_libs.torchvision.MinIoURandomCrop",

0 commit comments

Comments
 (0)