@@ -673,8 +673,8 @@ class RandomPerspective(torch.nn.Module):
673
673
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.BILINEAR``.
674
674
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
675
675
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable.
676
- fill (sequence or number, optional ): Pixel fill value for the area outside the transformed
677
- image. If given a number, the value is used for all bands respectively.
676
+ fill (sequence or number): Pixel fill value for the area outside the transformed
677
+ image. Default is ``0``. If given a number, the value is used for all bands respectively.
678
678
If input is PIL Image, the options is only available for ``Pillow>=5.0.0``.
679
679
"""
680
680
@@ -692,6 +692,12 @@ def __init__(self, distortion_scale=0.5, p=0.5, interpolation=InterpolationMode.
692
692
693
693
self .interpolation = interpolation
694
694
self .distortion_scale = distortion_scale
695
+
696
+ if fill is None :
697
+ fill = 0
698
+ elif not isinstance (fill , (Sequence , numbers .Number )):
699
+ raise TypeError ("Fill should be either a sequence or a number." )
700
+
695
701
self .fill = fill
696
702
697
703
def forward (self , img ):
@@ -1175,8 +1181,8 @@ class RandomRotation(torch.nn.Module):
1175
1181
Note that the expand flag assumes rotation around the center and no translation.
1176
1182
center (sequence, optional): Optional center of rotation, (x, y). Origin is the upper left corner.
1177
1183
Default is the center of the image.
1178
- fill (sequence or number, optional ): Pixel fill value for the area outside the rotated
1179
- image. If given a number, the value is used for all bands respectively.
1184
+ fill (sequence or number): Pixel fill value for the area outside the rotated
1185
+ image. Default is ``0``. If given a number, the value is used for all bands respectively.
1180
1186
If input is PIL Image, the options is only available for ``Pillow>=5.2.0``.
1181
1187
resample (int, optional): deprecated argument and will be removed since v0.10.0.
1182
1188
Please use the ``interpolation`` parameter instead.
@@ -1186,7 +1192,7 @@ class RandomRotation(torch.nn.Module):
1186
1192
"""
1187
1193
1188
1194
def __init__ (
1189
- self , degrees , interpolation = InterpolationMode .NEAREST , expand = False , center = None , fill = None , resample = None
1195
+ self , degrees , interpolation = InterpolationMode .NEAREST , expand = False , center = None , fill = 0 , resample = None
1190
1196
):
1191
1197
super ().__init__ ()
1192
1198
if resample is not None :
@@ -1212,6 +1218,12 @@ def __init__(
1212
1218
1213
1219
self .resample = self .interpolation = interpolation
1214
1220
self .expand = expand
1221
+
1222
+ if fill is None :
1223
+ fill = 0
1224
+ elif not isinstance (fill , (Sequence , numbers .Number )):
1225
+ raise TypeError ("Fill should be either a sequence or a number." )
1226
+
1215
1227
self .fill = fill
1216
1228
1217
1229
@staticmethod
@@ -1280,8 +1292,8 @@ class RandomAffine(torch.nn.Module):
1280
1292
:class:`torchvision.transforms.InterpolationMode`. Default is ``InterpolationMode.NEAREST``.
1281
1293
If input is Tensor, only ``InterpolationMode.NEAREST``, ``InterpolationMode.BILINEAR`` are supported.
1282
1294
For backward compatibility integer values (e.g. ``PIL.Image.NEAREST``) are still acceptable.
1283
- fill (sequence or number, optional ): Pixel fill value for the area outside the transformed
1284
- image. If given a number, the value is used for all bands respectively.
1295
+ fill (sequence or number): Pixel fill value for the area outside the transformed
1296
+ image. Default is ``0``. If given a number, the value is used for all bands respectively.
1285
1297
If input is PIL Image, the options is only available for ``Pillow>=5.0.0``.
1286
1298
fillcolor (sequence or number, optional): deprecated argument and will be removed since v0.10.0.
1287
1299
Please use the ``fill`` parameter instead.
@@ -1339,6 +1351,12 @@ def __init__(
1339
1351
self .shear = shear
1340
1352
1341
1353
self .resample = self .interpolation = interpolation
1354
+
1355
+ if fill is None :
1356
+ fill = 0
1357
+ elif not isinstance (fill , (Sequence , numbers .Number )):
1358
+ raise TypeError ("Fill should be either a sequence or a number." )
1359
+
1342
1360
self .fillcolor = self .fill = fill
1343
1361
1344
1362
@staticmethod
0 commit comments