@@ -3398,6 +3398,23 @@ def test_transform(self, old_format, new_format, format_type):
33983398 make_bounding_boxes (format = old_format ),
33993399 )
34003400
3401+ @pytest .mark .parametrize (("old_format" , "new_format" ), old_new_formats )
3402+ def test_strings (self , old_format , new_format ):
3403+ # Non-regression test for https://github.com/pytorch/vision/issues/8258
3404+ input = tv_tensors .BoundingBoxes (torch .tensor ([[10 , 10 , 20 , 20 ]]), format = old_format , canvas_size = (50 , 50 ))
3405+ expected = self ._reference_convert_bounding_box_format (input , new_format )
3406+
3407+ old_format = old_format .name
3408+ new_format = new_format .name
3409+
3410+ out_functional = F .convert_bounding_box_format (input , new_format = new_format )
3411+ out_functional_tensor = F .convert_bounding_box_format (
3412+ input .as_subclass (torch .Tensor ), old_format = old_format , new_format = new_format
3413+ )
3414+ out_transform = transforms .ConvertBoundingBoxFormat (new_format )(input )
3415+ for out in (out_functional , out_functional_tensor , out_transform ):
3416+ assert_equal (out , expected )
3417+
34013418 def _reference_convert_bounding_box_format (self , bounding_boxes , new_format ):
34023419 return tv_tensors .wrap (
34033420 torchvision .ops .box_convert (
0 commit comments