chore: 🧹 clean up unused imports and optimize code structure and convert more List to list

This commit is contained in:
Onuralp SEZER
2025-07-15 15:30:08 +03:00
parent a5155e23f2
commit b6cd9dd3f3
4 changed files with 9 additions and 9 deletions
+1 -1
View File
@@ -2052,7 +2052,7 @@ def merge_inner_detections_objects(
def merge_inner_detections_objects_without_iou(
detections: List[Detections],
detections: list[Detections],
) -> Detections:
"""
Given N detections each of length 1 (exactly one object inside), combine them into a
+6 -6
View File
@@ -169,7 +169,7 @@ def group_overlapping_boxes(
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
Returns:
List[List[int]]: Groups of prediction indices be merged.
list[list[int]]: Groups of prediction indices be merged.
Each group may have 1 or more elements.
"""
merge_groups: list[list[int]] = []
@@ -204,7 +204,7 @@ def mask_non_max_merge(
iou_threshold: float = 0.5,
mask_dimension: int = 640,
overlap_metric: OverlapMetric = OverlapMetric.IOU,
) -> List[List[int]]:
) -> list[list[int]]:
"""
Perform Non-Maximum Merging (NMM) on segmentation predictions.
@@ -277,7 +277,7 @@ def box_non_max_merge(
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
Returns:
List[List[int]]: Groups of prediction indices be merged.
list[list[int]]: Groups of prediction indices be merged.
Each group may have 1 or more elements.
"""
if predictions.shape[1] == 5:
@@ -307,7 +307,7 @@ def group_overlapping_masks(
masks: npt.NDArray[np.float64],
iou_threshold: float = 0.5,
overlap_metric: OverlapMetric = OverlapMetric.IOU,
) -> List[List[int]]:
) -> list[list[int]]:
"""
Apply greedy version of non-maximum merging to avoid detecting too many
@@ -322,10 +322,10 @@ def group_overlapping_masks(
overlap_metric (OverlapMetric): Metric used for matching detections in slices.
Returns:
List[List[int]]: Groups of prediction indices be merged.
list[list[int]]: Groups of prediction indices be merged.
Each group may have 1 or more elements.
"""
merge_groups: List[List[int]] = []
merge_groups: list[list[int]] = []
scores = predictions[:, 4]
order = scores.argsort()
+1 -1
View File
@@ -2,7 +2,7 @@ from __future__ import annotations
from enum import Enum
from itertools import chain
from typing import Any, Optional, Union
from typing import Any
import cv2
import numpy as np
+1 -1
View File
@@ -620,7 +620,7 @@ def test_mask_non_max_merge(
predictions: np.ndarray,
masks: np.ndarray,
iou_threshold: float,
expected_result: List[List[int]],
expected_result: list[list[int]],
exception: Exception,
) -> None:
with exception: