@@ -2081,7 +2081,6 @@ def test_functional(self, make_input):
20812081 (F .rotate_image , torch .Tensor ),
20822082 (F ._geometry ._rotate_image_pil , PIL .Image .Image ),
20832083 (F .rotate_image , tv_tensors .Image ),
2084- (F .rotate_bounding_boxes , tv_tensors .BoundingBoxes ),
20852084 (F .rotate_mask , tv_tensors .Mask ),
20862085 (F .rotate_video , tv_tensors .Video ),
20872086 (F .rotate_keypoints , tv_tensors .KeyPoints ),
@@ -2201,7 +2200,7 @@ def _recenter_bounding_boxes_after_expand(self, bounding_boxes, *, recenter_xy):
22012200 (bounding_boxes .to (torch .float64 ) - torch .tensor (translate )).to (bounding_boxes .dtype ), like = bounding_boxes
22022201 )
22032202
2204- def _reference_rotate_bounding_boxes (self , bounding_boxes , * , angle , expand , center , canvas_size = None ):
2203+ def _reference_rotate_bounding_boxes (self , bounding_boxes , * , angle , expand , center ):
22052204 if center is None :
22062205 center = [s * 0.5 for s in bounding_boxes .canvas_size [::- 1 ]]
22072206 cx , cy = center
@@ -2227,36 +2226,30 @@ def _reference_rotate_bounding_boxes(self, bounding_boxes, *, angle, expand, cen
22272226 output = helper (
22282227 bounding_boxes ,
22292228 affine_matrix = affine_matrix ,
2230- new_canvas_size = new_canvas_size if canvas_size is None else canvas_size ,
2229+ new_canvas_size = new_canvas_size ,
22312230 clamp = False ,
22322231 )
22332232
2234- return F .clamp_bounding_boxes (self ._recenter_bounding_boxes_after_expand (output , recenter_xy = recenter_xy )).to (
2235- bounding_boxes
2236- )
2233+ return self ._recenter_bounding_boxes_after_expand (output , recenter_xy = recenter_xy ).to (bounding_boxes )
22372234
22382235 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
22392236 @pytest .mark .parametrize ("angle" , _CORRECTNESS_AFFINE_KWARGS ["angle" ])
22402237 @pytest .mark .parametrize ("expand" , [False , True ])
22412238 @pytest .mark .parametrize ("center" , _CORRECTNESS_AFFINE_KWARGS ["center" ])
22422239 def test_functional_bounding_boxes_correctness (self , format , angle , expand , center ):
2243- bounding_boxes = make_bounding_boxes (format = format )
2240+ bounding_boxes = make_bounding_boxes (format = format , clamping_mode = "none" )
22442241
22452242 actual = F .rotate (bounding_boxes , angle = angle , expand = expand , center = center )
22462243 expected = self ._reference_rotate_bounding_boxes (bounding_boxes , angle = angle , expand = expand , center = center )
22472244 torch .testing .assert_close (F .get_size (actual ), F .get_size (expected ), atol = 2 if expand else 0 , rtol = 0 )
2248-
2249- expected = self ._reference_rotate_bounding_boxes (
2250- bounding_boxes , angle = angle , expand = expand , center = center , canvas_size = actual .canvas_size
2251- )
22522245 torch .testing .assert_close (actual , expected )
22532246
22542247 @pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
22552248 @pytest .mark .parametrize ("expand" , [False , True ])
22562249 @pytest .mark .parametrize ("center" , _CORRECTNESS_AFFINE_KWARGS ["center" ])
22572250 @pytest .mark .parametrize ("seed" , list (range (5 )))
22582251 def test_transform_bounding_boxes_correctness (self , format , expand , center , seed ):
2259- bounding_boxes = make_bounding_boxes (format = format )
2252+ bounding_boxes = make_bounding_boxes (format = format , clamping_mode = "none" )
22602253
22612254 transform = transforms .RandomRotation (** self ._CORRECTNESS_TRANSFORM_AFFINE_RANGES , expand = expand , center = center )
22622255
@@ -2268,10 +2261,6 @@ def test_transform_bounding_boxes_correctness(self, format, expand, center, seed
22682261
22692262 expected = self ._reference_rotate_bounding_boxes (bounding_boxes , ** params , expand = expand , center = center )
22702263 torch .testing .assert_close (F .get_size (actual ), F .get_size (expected ), atol = 2 if expand else 0 , rtol = 0 )
2271-
2272- expected = self ._reference_rotate_bounding_boxes (
2273- bounding_boxes , ** params , expand = expand , center = center , canvas_size = actual .canvas_size
2274- )
22752264 torch .testing .assert_close (actual , expected )
22762265
22772266 def _recenter_keypoints_after_expand (self , keypoints , * , recenter_xy ):
0 commit comments