@@ -2237,7 +2237,7 @@ def _reference_rotate_bounding_boxes(self, bounding_boxes, *, angle, expand, cen
2237
2237
@pytest .mark .parametrize ("expand" , [False , True ])
2238
2238
@pytest .mark .parametrize ("center" , _CORRECTNESS_AFFINE_KWARGS ["center" ])
2239
2239
def test_functional_bounding_boxes_correctness (self , format , angle , expand , center ):
2240
- bounding_boxes = make_bounding_boxes (format = format , clamping_mode = "none" )
2240
+ bounding_boxes = make_bounding_boxes (format = format , clamping_mode = None )
2241
2241
2242
2242
actual = F .rotate (bounding_boxes , angle = angle , expand = expand , center = center )
2243
2243
expected = self ._reference_rotate_bounding_boxes (bounding_boxes , angle = angle , expand = expand , center = center )
@@ -2249,7 +2249,7 @@ def test_functional_bounding_boxes_correctness(self, format, angle, expand, cent
2249
2249
@pytest .mark .parametrize ("center" , _CORRECTNESS_AFFINE_KWARGS ["center" ])
2250
2250
@pytest .mark .parametrize ("seed" , list (range (5 )))
2251
2251
def test_transform_bounding_boxes_correctness (self , format , expand , center , seed ):
2252
- bounding_boxes = make_bounding_boxes (format = format , clamping_mode = "none" )
2252
+ bounding_boxes = make_bounding_boxes (format = format , clamping_mode = None )
2253
2253
2254
2254
transform = transforms .RandomRotation (** self ._CORRECTNESS_TRANSFORM_AFFINE_RANGES , expand = expand , center = center )
2255
2255
@@ -4428,7 +4428,7 @@ def test_functional_bounding_boxes_correctness(self, format):
4428
4428
# _reference_resized_crop_bounding_boxes we are fusing the crop and the
4429
4429
# resize operation, where none of the croppings happen - particularly,
4430
4430
# the intermediate one.
4431
- bounding_boxes = make_bounding_boxes (self .INPUT_SIZE , format = format , clamping_mode = "none" )
4431
+ bounding_boxes = make_bounding_boxes (self .INPUT_SIZE , format = format , clamping_mode = None )
4432
4432
4433
4433
actual = F .resized_crop (bounding_boxes , ** self .CROP_KWARGS , size = self .OUTPUT_SIZE )
4434
4434
expected = self ._reference_resized_crop_bounding_boxes (
@@ -5507,7 +5507,7 @@ def test_correctness_image(self, mean, std, dtype, fn):
5507
5507
5508
5508
class TestClampBoundingBoxes :
5509
5509
@pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5510
- @pytest .mark .parametrize ("clamping_mode" , ("hard" , "none" )) # TODOBB add soft
5510
+ @pytest .mark .parametrize ("clamping_mode" , ("hard" , None )) # TODOBB add soft
5511
5511
@pytest .mark .parametrize ("dtype" , [torch .int64 , torch .float32 ])
5512
5512
@pytest .mark .parametrize ("device" , cpu_and_cuda ())
5513
5513
def test_kernel (self , format , clamping_mode , dtype , device ):
@@ -5521,7 +5521,7 @@ def test_kernel(self, format, clamping_mode, dtype, device):
5521
5521
)
5522
5522
5523
5523
@pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5524
- @pytest .mark .parametrize ("clamping_mode" , ("hard" , "none" )) # TODOBB add soft
5524
+ @pytest .mark .parametrize ("clamping_mode" , ("hard" , None )) # TODOBB add soft
5525
5525
def test_functional (self , format , clamping_mode ):
5526
5526
check_functional (F .clamp_bounding_boxes , make_bounding_boxes (format = format , clamping_mode = clamping_mode ))
5527
5527
@@ -5531,7 +5531,7 @@ def test_errors(self):
5531
5531
format , canvas_size = input_tv_tensor .format , input_tv_tensor .canvas_size
5532
5532
5533
5533
for format_ , canvas_size_ , clamping_mode_ in itertools .product (
5534
- (format , None ), (canvas_size , None ), (input_tv_tensor .clamping_mode , None )
5534
+ (format , None ), (canvas_size , None ), (input_tv_tensor .clamping_mode , "auto" )
5535
5535
):
5536
5536
with pytest .raises (
5537
5537
ValueError ,
@@ -5549,8 +5549,8 @@ def test_transform(self):
5549
5549
check_transform (transforms .ClampBoundingBoxes (), make_bounding_boxes ())
5550
5550
5551
5551
@pytest .mark .parametrize ("rotated" , (True , False ))
5552
- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , "none" ))
5553
- @pytest .mark .parametrize ("clamping_mode" , ("hard" , "none" , None )) # TODOBB add soft here.
5552
+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None ))
5553
+ @pytest .mark .parametrize ("clamping_mode" , ("hard" , None , "auto" )) # TODOBB add soft here.
5554
5554
@pytest .mark .parametrize ("pass_pure_tensor" , (True , False ))
5555
5555
@pytest .mark .parametrize ("fn" , [F .clamp_bounding_boxes , transform_cls_to_functional (transforms .ClampBoundingBoxes )])
5556
5556
def test_clamping_mode (self , rotated , constructor_clamping_mode , clamping_mode , pass_pure_tensor , fn ):
@@ -5559,15 +5559,15 @@ def test_clamping_mode(self, rotated, constructor_clamping_mode, clamping_mode,
5559
5559
# functional (or to the class) relies on the box's `.clamping_mode`
5560
5560
# attribute
5561
5561
# - That clamping happens when it should, and only when it should, i.e.
5562
- # when the clamping mode is not "none" . It doesn't validate the
5563
- # nunmerical results, only that clamping happened. For that, we create
5562
+ # when the clamping mode is not None . It doesn't validate the
5563
+ # numerical results, only that clamping happened. For that, we create
5564
5564
# a large 100x100 box inside of a small 10x10 image.
5565
5565
5566
5566
if pass_pure_tensor and fn is not F .clamp_bounding_boxes :
5567
5567
# Only the functional supports pure tensors, not the class
5568
5568
return
5569
- if pass_pure_tensor and clamping_mode is None :
5570
- # cannot leave clamping_mode=None when passing pure tensor
5569
+ if pass_pure_tensor and clamping_mode == "auto" :
5570
+ # cannot leave clamping_mode="auto" when passing pure tensor
5571
5571
return
5572
5572
5573
5573
if rotated :
@@ -5591,17 +5591,17 @@ def test_clamping_mode(self, rotated, constructor_clamping_mode, clamping_mode,
5591
5591
else :
5592
5592
out = fn (boxes , clamping_mode = clamping_mode )
5593
5593
5594
- clamping_mode_prevailing = constructor_clamping_mode if clamping_mode is None else clamping_mode
5595
- if clamping_mode_prevailing == "none" :
5594
+ clamping_mode_prevailing = constructor_clamping_mode if clamping_mode == "auto" else clamping_mode
5595
+ if clamping_mode_prevailing is None :
5596
5596
assert_equal (boxes , out ) # should be a pass-through
5597
5597
else :
5598
5598
assert_equal (out , expected_clamped_output )
5599
5599
5600
5600
5601
5601
class TestSetClampingMode :
5602
5602
@pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5603
- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , "none" )) # TODOBB add soft
5604
- @pytest .mark .parametrize ("desired_clamping_mode" , ("hard" , "none" )) # TODOBB add soft
5603
+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None )) # TODOBB add soft
5604
+ @pytest .mark .parametrize ("desired_clamping_mode" , ("hard" , None )) # TODOBB add soft
5605
5605
def test_setter (self , format , constructor_clamping_mode , desired_clamping_mode ):
5606
5606
5607
5607
in_boxes = make_bounding_boxes (format = format , clamping_mode = constructor_clamping_mode )
@@ -5611,7 +5611,7 @@ def test_setter(self, format, constructor_clamping_mode, desired_clamping_mode):
5611
5611
assert out_boxes .clamping_mode == desired_clamping_mode
5612
5612
5613
5613
@pytest .mark .parametrize ("format" , list (tv_tensors .BoundingBoxFormat ))
5614
- @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , "none" )) # TODOBB add soft
5614
+ @pytest .mark .parametrize ("constructor_clamping_mode" , ("hard" , None )) # TODOBB add soft
5615
5615
def test_pipeline_no_leak (self , format , constructor_clamping_mode ):
5616
5616
class AssertClampingMode (transforms .Transform ):
5617
5617
def __init__ (self , expected_clamping_mode ):
@@ -5626,12 +5626,12 @@ def transform(self, inpt, _):
5626
5626
5627
5627
t = transforms .Compose (
5628
5628
[
5629
- transforms .SetClampingMode ("none" ),
5630
- AssertClampingMode ("none" ),
5629
+ transforms .SetClampingMode (None ),
5630
+ AssertClampingMode (None ),
5631
5631
transforms .SetClampingMode ("hard" ),
5632
5632
AssertClampingMode ("hard" ),
5633
- transforms .SetClampingMode ("none" ),
5634
- AssertClampingMode ("none" ),
5633
+ transforms .SetClampingMode (None ),
5634
+ AssertClampingMode (None ),
5635
5635
transforms .ClampBoundingBoxes ("hard" ),
5636
5636
]
5637
5637
)
@@ -5643,7 +5643,7 @@ def transform(self, inpt, _):
5643
5643
5644
5644
# assert that the output boxes clamping_mode is the one set by the last SetClampingMode.
5645
5645
# ClampBoundingBoxes doesn't set clamping_mode.
5646
- assert out_boxes .clamping_mode == "none"
5646
+ assert out_boxes .clamping_mode is None
5647
5647
5648
5648
5649
5649
class TestClampKeyPoints :
0 commit comments