33import warnings
44from typing import Any , cast , List , Optional , Tuple , Union
55
6+ import PIL .Image
67import torch
78from torchvision ._utils import StrEnum
89from torchvision .transforms .functional import InterpolationMode , to_pil_image
910from torchvision .utils import draw_bounding_boxes , make_grid
1011
1112from ._bounding_box import BoundingBox
12- from ._feature import _Feature
13- from ._utils import FillType
13+ from ._feature import _Feature , FillTypeJIT
1414
1515
1616class ColorSpace (StrEnum ):
@@ -177,7 +177,7 @@ def resized_crop(
177177 def pad (
178178 self ,
179179 padding : Union [int , List [int ]],
180- fill : FillType = None ,
180+ fill : FillTypeJIT = None ,
181181 padding_mode : str = "constant" ,
182182 ) -> Image :
183183 output = self ._F .pad_image_tensor (self , padding , fill = fill , padding_mode = padding_mode )
@@ -188,7 +188,7 @@ def rotate(
188188 angle : float ,
189189 interpolation : InterpolationMode = InterpolationMode .NEAREST ,
190190 expand : bool = False ,
191- fill : FillType = None ,
191+ fill : FillTypeJIT = None ,
192192 center : Optional [List [float ]] = None ,
193193 ) -> Image :
194194 output = self ._F ._geometry .rotate_image_tensor (
@@ -203,7 +203,7 @@ def affine(
203203 scale : float ,
204204 shear : List [float ],
205205 interpolation : InterpolationMode = InterpolationMode .NEAREST ,
206- fill : FillType = None ,
206+ fill : FillTypeJIT = None ,
207207 center : Optional [List [float ]] = None ,
208208 ) -> Image :
209209 output = self ._F ._geometry .affine_image_tensor (
@@ -222,7 +222,7 @@ def perspective(
222222 self ,
223223 perspective_coeffs : List [float ],
224224 interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
225- fill : FillType = None ,
225+ fill : FillTypeJIT = None ,
226226 ) -> Image :
227227 output = self ._F ._geometry .perspective_image_tensor (
228228 self , perspective_coeffs , interpolation = interpolation , fill = fill
@@ -233,7 +233,7 @@ def elastic(
233233 self ,
234234 displacement : torch .Tensor ,
235235 interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
236- fill : FillType = None ,
236+ fill : FillTypeJIT = None ,
237237 ) -> Image :
238238 output = self ._F ._geometry .elastic_image_tensor (self , displacement , interpolation = interpolation , fill = fill )
239239 return Image .new_like (self , output )
@@ -285,3 +285,11 @@ def invert(self) -> Image:
285285 def gaussian_blur (self , kernel_size : List [int ], sigma : Optional [List [float ]] = None ) -> Image :
286286 output = self ._F .gaussian_blur_image_tensor (self , kernel_size = kernel_size , sigma = sigma )
287287 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