@@ -275,7 +275,7 @@ def test_common(self, transform, adapter, container_type, image_or_video, device
275
275
boxes = datapoints .BoundingBox ([[0 , 0 , 0 , 0 ]], format = format , spatial_size = (224 , 244 )),
276
276
labels = torch .tensor ([3 ]),
277
277
)
278
- assert transforms .SanitizeBoundingBoxes ()(sample )["boxes" ].shape == (0 , 4 )
278
+ assert transforms .SanitizeBoundingBox ()(sample )["boxes" ].shape == (0 , 4 )
279
279
280
280
@parametrize (
281
281
[
@@ -1876,7 +1876,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1876
1876
transforms .ConvertImageDtype (torch .float ),
1877
1877
]
1878
1878
if sanitize :
1879
- t += [transforms .SanitizeBoundingBoxes ()]
1879
+ t += [transforms .SanitizeBoundingBox ()]
1880
1880
t = transforms .Compose (t )
1881
1881
1882
1882
num_boxes = 5
@@ -1917,7 +1917,7 @@ def test_detection_preset(image_type, data_augmentation, to_tensor, sanitize):
1917
1917
# ssd and ssdlite contain RandomIoUCrop which may "remove" some bbox. It
1918
1918
# doesn't remove them strictly speaking, it just marks some boxes as
1919
1919
# degenerate and those boxes will be later removed by
1920
- # SanitizeBoundingBoxes (), which we add to the pipelines if the sanitize
1920
+ # SanitizeBoundingBox (), which we add to the pipelines if the sanitize
1921
1921
# param is True.
1922
1922
# Note that the values below are probably specific to the random seed
1923
1923
# set above (which is fine).
@@ -1989,7 +1989,7 @@ def test_sanitize_bounding_boxes(min_size, labels_getter, sample_type):
1989
1989
img = sample .pop ("image" )
1990
1990
sample = (img , sample )
1991
1991
1992
- out = transforms .SanitizeBoundingBoxes (min_size = min_size , labels_getter = labels_getter )(sample )
1992
+ out = transforms .SanitizeBoundingBox (min_size = min_size , labels_getter = labels_getter )(sample )
1993
1993
1994
1994
if sample_type is tuple :
1995
1995
out_image = out [0 ]
@@ -2023,13 +2023,13 @@ def test_sanitize_bounding_boxes_default_heuristic(key, sample_type):
2023
2023
sample = {key : labels , "another_key" : "whatever" }
2024
2024
if sample_type is tuple :
2025
2025
sample = (None , sample , "whatever_again" )
2026
- assert transforms .SanitizeBoundingBoxes ._find_labels_default_heuristic (sample ) is labels
2026
+ assert transforms .SanitizeBoundingBox ._find_labels_default_heuristic (sample ) is labels
2027
2027
2028
2028
if key .lower () != "labels" :
2029
2029
# If "labels" is in the dict (case-insensitive),
2030
2030
# it takes precedence over other keys which would otherwise be a match
2031
2031
d = {key : "something_else" , "labels" : labels }
2032
- assert transforms .SanitizeBoundingBoxes ._find_labels_default_heuristic (d ) is labels
2032
+ assert transforms .SanitizeBoundingBox ._find_labels_default_heuristic (d ) is labels
2033
2033
2034
2034
2035
2035
def test_sanitize_bounding_boxes_errors ():
@@ -2041,25 +2041,25 @@ def test_sanitize_bounding_boxes_errors():
2041
2041
)
2042
2042
2043
2043
with pytest .raises (ValueError , match = "min_size must be >= 1" ):
2044
- transforms .SanitizeBoundingBoxes (min_size = 0 )
2044
+ transforms .SanitizeBoundingBox (min_size = 0 )
2045
2045
with pytest .raises (ValueError , match = "labels_getter should either be a str" ):
2046
- transforms .SanitizeBoundingBoxes (labels_getter = 12 )
2046
+ transforms .SanitizeBoundingBox (labels_getter = 12 )
2047
2047
2048
2048
with pytest .raises (ValueError , match = "Could not infer where the labels are" ):
2049
2049
bad_labels_key = {"bbox" : good_bbox , "BAD_KEY" : torch .arange (good_bbox .shape [0 ])}
2050
- transforms .SanitizeBoundingBoxes ()(bad_labels_key )
2050
+ transforms .SanitizeBoundingBox ()(bad_labels_key )
2051
2051
2052
2052
with pytest .raises (ValueError , match = "If labels_getter is a str or 'default'" ):
2053
2053
not_a_dict = (good_bbox , torch .arange (good_bbox .shape [0 ]))
2054
- transforms .SanitizeBoundingBoxes ()(not_a_dict )
2054
+ transforms .SanitizeBoundingBox ()(not_a_dict )
2055
2055
2056
2056
with pytest .raises (ValueError , match = "must be a tensor" ):
2057
2057
not_a_tensor = {"bbox" : good_bbox , "labels" : torch .arange (good_bbox .shape [0 ]).tolist ()}
2058
- transforms .SanitizeBoundingBoxes ()(not_a_tensor )
2058
+ transforms .SanitizeBoundingBox ()(not_a_tensor )
2059
2059
2060
2060
with pytest .raises (ValueError , match = "Number of boxes" ):
2061
2061
different_sizes = {"bbox" : good_bbox , "labels" : torch .arange (good_bbox .shape [0 ] + 3 )}
2062
- transforms .SanitizeBoundingBoxes ()(different_sizes )
2062
+ transforms .SanitizeBoundingBox ()(different_sizes )
2063
2063
2064
2064
with pytest .raises (ValueError , match = "boxes must be of shape" ):
2065
2065
bad_bbox = datapoints .BoundingBox ( # batch with 2 elements
@@ -2071,7 +2071,7 @@ def test_sanitize_bounding_boxes_errors():
2071
2071
spatial_size = (20 , 20 ),
2072
2072
)
2073
2073
different_sizes = {"bbox" : bad_bbox , "labels" : torch .arange (bad_bbox .shape [0 ])}
2074
- transforms .SanitizeBoundingBoxes ()(different_sizes )
2074
+ transforms .SanitizeBoundingBox ()(different_sizes )
2075
2075
2076
2076
2077
2077
@pytest .mark .parametrize (
0 commit comments