def test_confidence_filtering(self, sample_boxes):
        """Test filtering based on confidence threshold."""
        # Set a confidence threshold of 0.7
        filter = BoxFiltering(confidence_threshold=0.7)
        filtered_boxes = filter(sample_boxes)

        # Expected output: only boxes with confidence > 0.7 should be kept
        assert len(filtered_boxes[0]) == 1  # Only one box in the first batch
        assert_almost_equal(filtered_boxes[0][0][1].item(), 0.9)  # Box with confidence 0.9
        assert len(filtered_boxes[1]) == 1  # Only one box in the second batch
        assert_almost_equal(filtered_boxes[1][0][1].item(), 0.95)  # Box with confidence 0.95
        assert len(filtered_boxes[2]) == 0  # No boxes in the third batch
Test filtering based on confidence threshold.
tests/models/box_filtering.py