From 45d0360fe85f52d0f5017cabd8823438e7936f33 Mon Sep 17 00:00:00 2001 From: Eugene Liu Date: Thu, 19 Dec 2024 17:04:05 +0000 Subject: [PATCH] Refactor import paths in D-FINE module and clean up unused code --- src/otx/algo/detection/d_fine.py | 2 +- src/otx/algo/detection/heads/dfine_decoder.py | 6 +----- src/otx/algo/detection/losses/dfine_loss.py | 2 +- 3 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/otx/algo/detection/d_fine.py b/src/otx/algo/detection/d_fine.py index f42aa25e3b..a9f7b6e57b 100644 --- a/src/otx/algo/detection/d_fine.py +++ b/src/otx/algo/detection/d_fine.py @@ -16,7 +16,7 @@ from otx.algo.detection.backbones.hgnetv2 import HGNetv2 from otx.algo.detection.detectors import DETR -from otx.algo.detection.detectors.dfine.dfine_decoder import DFINETransformer +from otx.algo.detection.heads.dfine_decoder import DFINETransformer from otx.algo.detection.losses.dfine_loss import DFINECriterion from otx.algo.detection.necks.dfine_hybrid_encoder import HybridEncoder from otx.algo.utils.mmengine_utils import load_checkpoint diff --git a/src/otx/algo/detection/heads/dfine_decoder.py b/src/otx/algo/detection/heads/dfine_decoder.py index c2c6cec5dd..be3085227f 100644 --- a/src/otx/algo/detection/heads/dfine_decoder.py +++ b/src/otx/algo/detection/heads/dfine_decoder.py @@ -14,11 +14,11 @@ import torch.nn.functional as f from torch import Tensor, nn from torch.nn import init +from torchvision.ops import box_convert from otx.algo.common.utils.utils import inverse_sigmoid from otx.algo.detection.heads.rtdetr_decoder import get_contrastive_denoising_training_group from otx.algo.utils.weight_init import bias_init_with_prob -from torchvision.ops import box_convert def weighting_function(reg_max: int, up: Tensor, reg_scale: Tensor) -> Tensor: @@ -68,9 +68,6 @@ def distance2bbox(points: Tensor, distance: Tensor, reg_scale: float): return box_convert(bboxes, in_fmt="xyxy", out_fmt="cxcywh") - - - def get_activation( act: str, inplace: bool = True, @@ -103,7 +100,6 @@ def get_activation( return m - def deformable_attention_core_func_v2( value: torch.Tensor, value_spatial_shapes, diff --git a/src/otx/algo/detection/losses/dfine_loss.py b/src/otx/algo/detection/losses/dfine_loss.py index 17ed4f9bcd..6540c802f3 100644 --- a/src/otx/algo/detection/losses/dfine_loss.py +++ b/src/otx/algo/detection/losses/dfine_loss.py @@ -16,7 +16,6 @@ from otx.algo.common.utils.assigners.hungarian_matcher import HungarianMatcher from otx.algo.common.utils.bbox_overlaps import bbox_overlaps - from otx.algo.detection.heads.dfine_decoder import weighting_function @@ -86,6 +85,7 @@ def translate_gt(gt: Tensor, reg_max: int, reg_scale: Tensor, up: Tensor) -> tup return indices, weight_right, weight_left + def bbox2distance( points: Tensor, bbox: Tensor,