@@ -255,9 +255,7 @@ def _extract_params_for_v1_transform(self) -> Dict[str, Any]:
255
255
params = super ()._extract_params_for_v1_transform ()
256
256
257
257
if not (params ["fill" ] is None or isinstance (params ["fill" ], (int , float ))):
258
- raise ValueError (
259
- f"{ type (self .__name__ )} () can only be scripted for a scalar `fill`, but got { self .fill } for images."
260
- )
258
+ raise ValueError (f"{ type (self ).__name__ } () can only be scripted for a scalar `fill`, but got { self .fill } ." )
261
259
262
260
return params
263
261
@@ -276,11 +274,12 @@ def __init__(
276
274
if not isinstance (padding , int ):
277
275
padding = list (padding )
278
276
self .padding = padding
279
- self .fill = _setup_fill_arg (fill )
277
+ self .fill = fill
278
+ self ._fill = _setup_fill_arg (fill )
280
279
self .padding_mode = padding_mode
281
280
282
281
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
283
- fill = self .fill [type (inpt )]
282
+ fill = self ._fill [type (inpt )]
284
283
return F .pad (inpt , padding = self .padding , fill = fill , padding_mode = self .padding_mode ) # type: ignore[arg-type]
285
284
286
285
@@ -293,7 +292,8 @@ def __init__(
293
292
) -> None :
294
293
super ().__init__ (p = p )
295
294
296
- self .fill = _setup_fill_arg (fill )
295
+ self .fill = fill
296
+ self ._fill = _setup_fill_arg (fill )
297
297
298
298
_check_sequence_input (side_range , "side_range" , req_sizes = (2 ,))
299
299
@@ -318,7 +318,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
318
318
return dict (padding = padding )
319
319
320
320
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
321
- fill = self .fill [type (inpt )]
321
+ fill = self ._fill [type (inpt )]
322
322
return F .pad (inpt , ** params , fill = fill )
323
323
324
324
@@ -338,7 +338,8 @@ def __init__(
338
338
self .interpolation = _check_interpolation (interpolation )
339
339
self .expand = expand
340
340
341
- self .fill = _setup_fill_arg (fill )
341
+ self .fill = fill
342
+ self ._fill = _setup_fill_arg (fill )
342
343
343
344
if center is not None :
344
345
_check_sequence_input (center , "center" , req_sizes = (2 ,))
@@ -350,7 +351,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
350
351
return dict (angle = angle )
351
352
352
353
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
353
- fill = self .fill [type (inpt )]
354
+ fill = self ._fill [type (inpt )]
354
355
return F .rotate (
355
356
inpt ,
356
357
** params ,
@@ -395,7 +396,8 @@ def __init__(
395
396
self .shear = shear
396
397
397
398
self .interpolation = _check_interpolation (interpolation )
398
- self .fill = _setup_fill_arg (fill )
399
+ self .fill = fill
400
+ self ._fill = _setup_fill_arg (fill )
399
401
400
402
if center is not None :
401
403
_check_sequence_input (center , "center" , req_sizes = (2 ,))
@@ -430,7 +432,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
430
432
return dict (angle = angle , translate = translate , scale = scale , shear = shear )
431
433
432
434
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
433
- fill = self .fill [type (inpt )]
435
+ fill = self ._fill [type (inpt )]
434
436
return F .affine (
435
437
inpt ,
436
438
** params ,
@@ -447,9 +449,7 @@ def _extract_params_for_v1_transform(self) -> Dict[str, Any]:
447
449
params = super ()._extract_params_for_v1_transform ()
448
450
449
451
if not (params ["fill" ] is None or isinstance (params ["fill" ], (int , float ))):
450
- raise ValueError (
451
- f"{ type (self .__name__ )} () can only be scripted for a scalar `fill`, but got { self .fill } for images."
452
- )
452
+ raise ValueError (f"{ type (self ).__name__ } () can only be scripted for a scalar `fill`, but got { self .fill } ." )
453
453
454
454
padding = self .padding
455
455
if padding is not None :
@@ -478,7 +478,8 @@ def __init__(
478
478
479
479
self .padding = F ._geometry ._parse_pad_padding (padding ) if padding else None # type: ignore[arg-type]
480
480
self .pad_if_needed = pad_if_needed
481
- self .fill = _setup_fill_arg (fill )
481
+ self .fill = fill
482
+ self ._fill = _setup_fill_arg (fill )
482
483
self .padding_mode = padding_mode
483
484
484
485
def _get_params (self , flat_inputs : List [Any ]) -> Dict [str , Any ]:
@@ -541,7 +542,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
541
542
542
543
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
543
544
if params ["needs_pad" ]:
544
- fill = self .fill [type (inpt )]
545
+ fill = self ._fill [type (inpt )]
545
546
inpt = F .pad (inpt , padding = params ["padding" ], fill = fill , padding_mode = self .padding_mode )
546
547
547
548
if params ["needs_crop" ]:
@@ -567,7 +568,8 @@ def __init__(
567
568
568
569
self .distortion_scale = distortion_scale
569
570
self .interpolation = _check_interpolation (interpolation )
570
- self .fill = _setup_fill_arg (fill )
571
+ self .fill = fill
572
+ self ._fill = _setup_fill_arg (fill )
571
573
572
574
def _get_params (self , flat_inputs : List [Any ]) -> Dict [str , Any ]:
573
575
height , width = query_spatial_size (flat_inputs )
@@ -600,7 +602,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
600
602
return dict (coefficients = perspective_coeffs )
601
603
602
604
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
603
- fill = self .fill [type (inpt )]
605
+ fill = self ._fill [type (inpt )]
604
606
return F .perspective (
605
607
inpt ,
606
608
None ,
@@ -626,7 +628,8 @@ def __init__(
626
628
self .sigma = _setup_float_or_seq (sigma , "sigma" , 2 )
627
629
628
630
self .interpolation = _check_interpolation (interpolation )
629
- self .fill = _setup_fill_arg (fill )
631
+ self .fill = fill
632
+ self ._fill = _setup_fill_arg (fill )
630
633
631
634
def _get_params (self , flat_inputs : List [Any ]) -> Dict [str , Any ]:
632
635
size = list (query_spatial_size (flat_inputs ))
@@ -652,7 +655,7 @@ def _get_params(self, flat_inputs: List[Any]) -> Dict[str, Any]:
652
655
return dict (displacement = displacement )
653
656
654
657
def _transform (self , inpt : Any , params : Dict [str , Any ]) -> Any :
655
- fill = self .fill [type (inpt )]
658
+ fill = self ._fill [type (inpt )]
656
659
return F .elastic (
657
660
inpt ,
658
661
** params ,
0 commit comments