@@ -6201,7 +6201,18 @@ def test_kernel_image(self, dtype, device):
62016201 def test_kernel_video (self ):
62026202 check_kernel (F .adjust_hue_video , make_video (), hue_factor = 0.25 )
62036203
6204- @pytest .mark .parametrize ("make_input" , [make_image_tensor , make_image , make_image_pil , make_video ])
6204+ @pytest .mark .parametrize (
6205+ "make_input" ,
6206+ [
6207+ make_image_tensor ,
6208+ make_image ,
6209+ make_image_pil ,
6210+ make_video ,
6211+ pytest .param (
6212+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" )
6213+ ),
6214+ ],
6215+ )
62056216 def test_functional (self , make_input ):
62066217 check_functional (F .adjust_hue , make_input (), hue_factor = 0.25 )
62076218
@@ -6212,9 +6223,16 @@ def test_functional(self, make_input):
62126223 (F ._color ._adjust_hue_image_pil , PIL .Image .Image ),
62136224 (F .adjust_hue_image , tv_tensors .Image ),
62146225 (F .adjust_hue_video , tv_tensors .Video ),
6226+ pytest .param (
6227+ F ._color ._adjust_hue_cvcuda ,
6228+ "cvcuda.Tensor" ,
6229+ marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" ),
6230+ ),
62156231 ],
62166232 )
62176233 def test_functional_signature (self , kernel , input_type ):
6234+ if input_type == "cvcuda.Tensor" :
6235+ input_type = _import_cvcuda ().Tensor
62186236 check_functional_kernel_signature_match (F .adjust_hue , kernel = kernel , input_type = input_type )
62196237
62206238 def test_functional_error (self ):
@@ -6225,11 +6243,27 @@ def test_functional_error(self):
62256243 with pytest .raises (ValueError , match = re .escape ("is not in [-0.5, 0.5]" )):
62266244 F .adjust_hue (make_image (), hue_factor = hue_factor )
62276245
6246+ @pytest .mark .parametrize (
6247+ "make_input" ,
6248+ [
6249+ make_image ,
6250+ pytest .param (
6251+ make_image_cvcuda , marks = pytest .mark .skipif (not CVCUDA_AVAILABLE , reason = "CVCUDA not available" )
6252+ ),
6253+ ],
6254+ )
62286255 @pytest .mark .parametrize ("hue_factor" , [- 0.5 , - 0.3 , 0.0 , 0.2 , 0.5 ])
6229- def test_correctness_image (self , hue_factor ):
6230- image = make_image (dtype = torch .uint8 , device = "cpu" )
6256+ def test_correctness_image (self , make_input , hue_factor ):
6257+ image = make_input (dtype = torch .uint8 , device = "cpu" )
62316258
62326259 actual = F .adjust_hue (image , hue_factor = hue_factor )
6260+
6261+ if make_input is make_image_cvcuda :
6262+ actual = F .cvcuda_to_tensor (actual ).to (device = "cpu" )
6263+ actual = actual .squeeze (0 )
6264+ image = F .cvcuda_to_tensor (image )
6265+ image = image .squeeze (0 )
6266+
62336267 expected = F .to_image (F .adjust_hue (F .to_pil_image (image ), hue_factor = hue_factor ))
62346268
62356269 mae = (actual .float () - expected .float ()).abs ().mean ()
0 commit comments