remove ultralytics tests

This commit is contained in:
SkalskiP committed 2025-11-14 12:38:55 +01:00
1 parent 61cca76acc
commit 35272b40d3
1 file changed
-84
-84
View File
@@ -815,87 +815,3 @@ def test_merge_inner_detection_object_pair(
with exception:
result = merge_inner_detection_object_pair(detection_1, detection_2)
assert result == expected_result
class TestFromUltralytics:
"""Test suite for Detections.from_ultralytics method."""
def test_from_ultralytics_with_missing_boxes_attribute(self):
"""Test that from_ultralytics handles missing boxes attribute gracefully.
Regression test for issue #2000.
"""
# Create a mock ultralytics result without boxes attribute
class MockUltralyticsResult:
def __init__(self):
self.names = {0: "class1", 1: "class2"}
# Intentionally not setting 'boxes' or 'obb' attribute
mock_result = MockUltralyticsResult()
detections = Detections.from_ultralytics(mock_result)
# Should return empty detections instead of crashing
assert len(detections) == 0
assert detections.xyxy.shape == (0, 4)
def test_from_ultralytics_with_boxes_none(self):
"""Test that from_ultralytics handles boxes=None (segmentation-only models)."""
# Create a mock ultralytics result with boxes=None
class MockUltralyticsResult:
def __init__(self):
self.boxes = None
self.names = {0: "class1"}
# Mock masks attribute for segmentation
self.masks = None
mock_result = MockUltralyticsResult()
# This should handle the segmentation-only case
# Note: Will fail if masks are not properly set, but that's expected behavior
try:
_ = Detections.from_ultralytics(mock_result)
# If masks are properly implemented, this should work
except (AttributeError, TypeError):
# Expected if masks aren't properly mocked
pass
def test_from_ultralytics_with_valid_boxes(self):
"""Test that from_ultralytics works correctly with valid boxes."""
# Create a mock ultralytics result with valid boxes
class MockBoxes:
def __init__(self):
self.cls = self._MockTensor([0, 1])
self.xyxy = self._MockTensor([[10, 20, 30, 40], [50, 60, 70, 80]])
self.conf = self._MockTensor([0.9, 0.8])
self.id = None
class _MockTensor:
def __init__(self, data):
self.data = np.array(data)
def cpu(self):
return self
def numpy(self):
return self.data
def astype(self, dtype):
return self.data.astype(dtype)
class MockUltralyticsResult:
def __init__(self):
self.boxes = MockBoxes()
self.names = {0: "person", 1: "car"}
self.masks = None
mock_result = MockUltralyticsResult()
detections = Detections.from_ultralytics(mock_result)
assert len(detections) == 2
assert np.array_equal(
detections.xyxy, np.array([[10, 20, 30, 40], [50, 60, 70, 80]])
)
assert np.array_equal(detections.confidence, np.array([0.9, 0.8]))
assert np.array_equal(detections.class_id, np.array([0, 1]))