Skip to content

Commit

Permalink
Move OV semantic segmentation tiler to use MAPI (#3978)
Browse files Browse the repository at this point in the history
* Use sseg tiler from MAPI

* Upgrade MAPI

* Update seg tiling tests
  • Loading branch information
sovrasov authored Sep 27, 2024
1 parent b56ced7 commit a25a94f
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 69 deletions.
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ xpu = [
"timm==1.0.3",
"openvino==2024.4",
"openvino-dev==2024.4",
"openvino-model-api==0.2.3",
"openvino-model-api==0.2.4",
"onnx==1.16.2",
"onnxconverter-common==1.14.0",
"nncf==2.13.0",
Expand All @@ -94,7 +94,7 @@ base = [
"timm==1.0.3",
"openvino==2024.4",
"openvino-dev==2024.4",
"openvino-model-api==0.2.3",
"openvino-model-api==0.2.4",
"onnx==1.16.2",
"onnxconverter-common==1.14.0",
"nncf==2.13.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
openvino==2024.4.0
openvino-model-api==0.2.3
openvino-model-api==0.2.4
numpy==1.26.4
61 changes: 0 additions & 61 deletions src/otx/core/model/seg_tiler.py

This file was deleted.

4 changes: 2 additions & 2 deletions src/otx/core/model/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

import torch
import torch.nn.functional as f
from model_api.tilers import SemanticSegmentationTiler
from torch import nn
from torchvision import tv_tensors

Expand All @@ -26,7 +27,6 @@
from otx.core.metrics import MetricInput
from otx.core.metrics.dice import SegmCallable
from otx.core.model.base import DefaultOptimizerCallable, DefaultSchedulerCallable, OTXModel, OVModel
from otx.core.model.seg_tiler import SegTiler
from otx.core.schedulers import LRSchedulerListCallable
from otx.core.types.export import OTXExportFormatType, TaskLevelExportParameters
from otx.core.types.label import LabelInfo, LabelInfoTypes, SegLabelInfo
Expand Down Expand Up @@ -360,7 +360,7 @@ def _setup_tiler(self) -> None:
execution_mode = "async" if self.async_inference else "sync"
# Note: Disable async_inference as tiling has its own sync/async implementation
self.async_inference = False
self.model = SegTiler(self.model, execution_mode=execution_mode)
self.model = SemanticSegmentationTiler(self.model, execution_mode=execution_mode)
log.info(
f"Enable tiler with tile size: {self.model.tile_size} \
and overlap: {self.model.tiles_overlap}",
Expand Down
6 changes: 3 additions & 3 deletions tests/unit/core/data/test_tiling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from datumaro import Polygon
from model_api.models import Model
from model_api.models.utils import ImageResultWithSoftPrediction
from model_api.tilers import SemanticSegmentationTiler
from omegaconf import OmegaConf
from otx.algo.detection.atss import ATSS
from otx.algo.instance_segmentation.maskrcnn import MaskRCNN
Expand All @@ -31,7 +32,6 @@
from otx.core.data.entity.tile import TileBatchDetDataEntity, TileBatchInstSegDataEntity, TileBatchSegDataEntity
from otx.core.data.module import OTXDataModule
from otx.core.model.detection import OTXDetectionModel
from otx.core.model.seg_tiler import SegTiler
from otx.core.types.task import OTXTaskType
from otx.core.types.transformer_libs import TransformLibType
from torchvision import tv_tensors
Expand Down Expand Up @@ -522,11 +522,11 @@ def test_seg_tiler(self, mocker):

mock_model = MagicMock(spec=Model)
mocker.patch("model_api.tilers.tiler.Tiler.__init__", return_value=None)
mocker.patch.multiple(SegTiler, __abstractmethods__=set())
mocker.patch.multiple(SemanticSegmentationTiler, __abstractmethods__=set())

num_labels = rng.integers(low=1, high=10)

tiler = SegTiler(model=mock_model)
tiler = SemanticSegmentationTiler(model=mock_model)
tiler.model = mock_model
tiler.model.labels = [f"label{i}" for i in range(num_labels)]
tiler.tile_with_full_img = True
Expand Down

0 comments on commit a25a94f

Please sign in to comment.