Skip to content

Commit

Permalink
Merge branch 'kp/move_xpu_prs' of https://github.com/openvinotoolkit/…
Browse files Browse the repository at this point in the history
…training_extensions into kp/move_xpu_prs
  • Loading branch information
kprokofi committed Apr 12, 2024
2 parents 7ea22a9 + 8a73f9e commit 093dc4a
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 22 deletions.
4 changes: 2 additions & 2 deletions src/otx/algo/accelerators/xpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
import torch
from lightning.pytorch.accelerators import AcceleratorRegistry
from lightning.pytorch.accelerators.accelerator import Accelerator
from mmengine.structures import instance_data

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 Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
from typing import TYPE_CHECKING

import torch
from mmcv.cnn import build_activation_layer
from mmengine.model import constant_init, normal_init
from mmpretrain.models.heads import MultiLabelClsHead
from mmpretrain.registry import MODELS
from torch import nn

from mmcv.cnn import build_activation_layer

from .custom_multilabel_linear_cls_head import AnglularLinear

if TYPE_CHECKING:
Expand Down
3 changes: 1 addition & 2 deletions src/otx/algo/detection/backbones/pytorchcv_backbones.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,14 @@
from typing import TYPE_CHECKING

import torch
from mmcv.cnn import build_activation_layer, build_norm_layer
from mmdet.registry import MODELS
from mmengine.dist import get_dist_info
from pytorchcv.model_provider import _models
from pytorchcv.models.model_store import download_model
from torch import distributed, nn
from torch.nn.modules.batchnorm import _BatchNorm

from mmcv.cnn import build_activation_layer, build_norm_layer

if TYPE_CHECKING:
from mmdet.registry import Registry
from mmengine.config import Config, ConfigDict
Expand Down
3 changes: 1 addition & 2 deletions src/otx/algo/detection/utils/mmcv_patched_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,10 @@
from typing import TYPE_CHECKING

import torch
from mmcv.utils import ext_loader
from torchvision.ops import nms as tv_nms
from torchvision.ops import roi_align as tv_roi_align

from mmcv.utils import ext_loader

if TYPE_CHECKING:
from mmcv.ops.nms import NMSop
from mmcv.ops.roi_align import RoIAlign
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import torch
import torch.nn.functional as F # noqa: N812
from mmcv.ops import RoIAlign, batched_nms
from mmdeploy.codebase.mmdet import get_post_processing_params
from mmdeploy.codebase.mmdet.models.dense_heads.rtmdet_ins_head import _parse_dynamic_params
from mmdeploy.core import FUNCTION_REWRITER
Expand All @@ -19,8 +20,6 @@
from mmdet.structures.bbox import get_box_tensor, get_box_wh, scale_boxes
from mmengine.config import ConfigDict

from mmcv.ops import RoIAlign, batched_nms

if TYPE_CHECKING:
from mmengine.structures import InstanceData

Expand Down
2 changes: 1 addition & 1 deletion src/otx/algo/segmentation/backbones/litehrnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@

import torch
import torch.utils.checkpoint as cp
from mmcv.cnn import ConvModule, build_conv_layer, build_norm_layer
from mmengine.model import BaseModule
from mmengine.utils import is_tuple_of
from mmseg.registry import MODELS
from torch import nn
from torch.nn import functional

from mmcv.cnn import ConvModule, build_conv_layer, build_norm_layer
from otx.algo.utils.segmentation import (
AsymmetricPositionAttentionModule,
IterativeAggregator,
Expand Down
3 changes: 1 addition & 2 deletions src/otx/algo/utils/segmentation.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

import torch
import torch.nn.functional as f
from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule
from torch import nn
from torch.nn import AdaptiveAvgPool2d, AdaptiveMaxPool2d

from mmcv.cnn import ConvModule, DepthwiseSeparableConvModule


def channel_shuffle(x: torch.Tensor, groups: int) -> torch.Tensor:
"""Channel Shuffle operation.
Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/transform_libs/mmaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
from pathlib import Path
from typing import TYPE_CHECKING, Any, Callable

import mmcv
import numpy as np
from mmaction.datasets.transforms import PackActionInputs as MMPackActionInputs
from mmaction.datasets.transforms import RawFrameDecode as MMRawFrameDecode
from mmaction.registry import TRANSFORMS
from mmengine.fileio import FileClient
from torchvision import tv_tensors

import mmcv
from otx.core.data.entity.action_classification import ActionClsDataEntity
from otx.core.data.entity.action_detection import ActionDetDataEntity
from otx.core.utils.config import convert_conf_to_mmconfig_dict
Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/transform_libs/mmcv.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
from typing import TYPE_CHECKING, Callable

import numpy as np

from mmcv.transforms import LoadImageFromFile as MMCVLoadImageFromFile
from mmcv.transforms.builder import TRANSFORMS

from otx.core.data.entity.base import OTXDataEntity
from otx.core.utils.config import convert_conf_to_mmconfig_dict

Expand Down
2 changes: 1 addition & 1 deletion src/otx/core/data/transform_libs/mmdet.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
import numpy as np
import torch
from datumaro import Polygon
from mmcv.transforms import BaseTransform
from mmdet.datasets.transforms import LoadAnnotations as MMDetLoadAnnotations
from mmdet.datasets.transforms import PackDetInputs as MMDetPackDetInputs
from mmdet.registry import TRANSFORMS as MMDET_TRANSFORMS
from mmdet.structures.mask import BitmapMasks, PolygonMasks
from mmengine.registry import Registry
from torchvision import tv_tensors

from mmcv.transforms import BaseTransform
from otx.core.data.entity.base import ImageInfo
from otx.core.data.entity.detection import DetDataEntity
from otx.core.data.entity.instance_segmentation import InstanceSegDataEntity
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/algo/detection/utils/test_mmcv_patched_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,8 @@

import pytest
import torch
from otx.algo.detection.utils.mmcv_patched_ops import monkey_patched_nms

from mmcv.ops import nms
from otx.algo.detection.utils.mmcv_patched_ops import monkey_patched_nms


class TestMonkeyPatchedNMS:
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/core/data/transform_libs/test_mmaction.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
#

import mmcv
import numpy as np
import pytest
import torch
Expand All @@ -21,8 +22,6 @@
)
from otx.core.types.transformer_libs import TransformLibType

import mmcv


class MockVideo:
path: str = "video_path"
Expand Down
3 changes: 1 addition & 2 deletions tests/unit/core/data/transform_libs/test_mmcv.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,12 @@

import numpy as np
import pytest
from mmcv.transforms.builder import TRANSFORMS
from otx.core.config.data import SubsetConfig
from otx.core.data.entity.base import ImageInfo, OTXDataEntity
from otx.core.data.transform_libs.mmcv import LoadImageFromFile, MMCVTransformLib
from otx.core.types.transformer_libs import TransformLibType

from mmcv.transforms.builder import TRANSFORMS


class TestLoadImageFromFile:
def test_transform(self) -> None:
Expand Down

0 comments on commit 093dc4a

Please sign in to comment.