3
3
import warnings
4
4
from typing import Any , cast , List , Optional , Tuple , Union
5
5
6
+ import PIL .Image
6
7
import torch
7
8
from torchvision ._utils import StrEnum
8
9
from torchvision .transforms .functional import InterpolationMode , to_pil_image
9
10
from torchvision .utils import draw_bounding_boxes , make_grid
10
11
11
12
from ._bounding_box import BoundingBox
12
- from ._feature import _Feature
13
- from ._utils import FillType
13
+ from ._feature import _Feature , FillTypeJIT
14
14
15
15
16
16
class ColorSpace (StrEnum ):
@@ -177,7 +177,7 @@ def resized_crop(
177
177
def pad (
178
178
self ,
179
179
padding : Union [int , List [int ]],
180
- fill : FillType = None ,
180
+ fill : FillTypeJIT = None ,
181
181
padding_mode : str = "constant" ,
182
182
) -> Image :
183
183
output = self ._F .pad_image_tensor (self , padding , fill = fill , padding_mode = padding_mode )
@@ -188,7 +188,7 @@ def rotate(
188
188
angle : float ,
189
189
interpolation : InterpolationMode = InterpolationMode .NEAREST ,
190
190
expand : bool = False ,
191
- fill : FillType = None ,
191
+ fill : FillTypeJIT = None ,
192
192
center : Optional [List [float ]] = None ,
193
193
) -> Image :
194
194
output = self ._F ._geometry .rotate_image_tensor (
@@ -203,7 +203,7 @@ def affine(
203
203
scale : float ,
204
204
shear : List [float ],
205
205
interpolation : InterpolationMode = InterpolationMode .NEAREST ,
206
- fill : FillType = None ,
206
+ fill : FillTypeJIT = None ,
207
207
center : Optional [List [float ]] = None ,
208
208
) -> Image :
209
209
output = self ._F ._geometry .affine_image_tensor (
@@ -222,7 +222,7 @@ def perspective(
222
222
self ,
223
223
perspective_coeffs : List [float ],
224
224
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
225
- fill : FillType = None ,
225
+ fill : FillTypeJIT = None ,
226
226
) -> Image :
227
227
output = self ._F ._geometry .perspective_image_tensor (
228
228
self , perspective_coeffs , interpolation = interpolation , fill = fill
@@ -233,7 +233,7 @@ def elastic(
233
233
self ,
234
234
displacement : torch .Tensor ,
235
235
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
236
- fill : FillType = None ,
236
+ fill : FillTypeJIT = None ,
237
237
) -> Image :
238
238
output = self ._F ._geometry .elastic_image_tensor (self , displacement , interpolation = interpolation , fill = fill )
239
239
return Image .new_like (self , output )
@@ -285,3 +285,11 @@ def invert(self) -> Image:
285
285
def gaussian_blur (self , kernel_size : List [int ], sigma : Optional [List [float ]] = None ) -> Image :
286
286
output = self ._F .gaussian_blur_image_tensor (self , kernel_size = kernel_size , sigma = sigma )
287
287
return Image .new_like (self , output )
288
+
289
+
290
+ ImageType = Union [torch .Tensor , PIL .Image .Image , Image ]
291
+ ImageTypeJIT = torch .Tensor
292
+ LegacyImageType = Union [torch .Tensor , PIL .Image .Image ]
293
+ LegacyImageTypeJIT = torch .Tensor
294
+ TensorImageType = Union [torch .Tensor , Image ]
295
+ TensorImageTypeJIT = torch .Tensor
0 commit comments