@@ -117,17 +117,17 @@ def to_color_space(self, color_space: Union[str, ColorSpace], copy: bool = True)
117117 return Image .wrap_like (
118118 self ,
119119 self ._F .convert_color_space_image_tensor (
120- self , old_color_space = self .color_space , new_color_space = color_space , copy = copy
120+ self . as_subclass ( torch . Tensor ) , old_color_space = self .color_space , new_color_space = color_space , copy = copy
121121 ),
122122 color_space = color_space ,
123123 )
124124
125125 def horizontal_flip (self ) -> Image :
126- output = self ._F .horizontal_flip_image_tensor (self )
126+ output = self ._F .horizontal_flip_image_tensor (self . as_subclass ( torch . Tensor ) )
127127 return Image .wrap_like (self , output )
128128
129129 def vertical_flip (self ) -> Image :
130- output = self ._F .vertical_flip_image_tensor (self )
130+ output = self ._F .vertical_flip_image_tensor (self . as_subclass ( torch . Tensor ) )
131131 return Image .wrap_like (self , output )
132132
133133 def resize ( # type: ignore[override]
@@ -138,16 +138,16 @@ def resize( # type: ignore[override]
138138 antialias : bool = False ,
139139 ) -> Image :
140140 output = self ._F .resize_image_tensor (
141- self , size , interpolation = interpolation , max_size = max_size , antialias = antialias
141+ self . as_subclass ( torch . Tensor ) , size , interpolation = interpolation , max_size = max_size , antialias = antialias
142142 )
143143 return Image .wrap_like (self , output )
144144
145145 def crop (self , top : int , left : int , height : int , width : int ) -> Image :
146- output = self ._F .crop_image_tensor (self , top , left , height , width )
146+ output = self ._F .crop_image_tensor (self . as_subclass ( torch . Tensor ) , top , left , height , width )
147147 return Image .wrap_like (self , output )
148148
149149 def center_crop (self , output_size : List [int ]) -> Image :
150- output = self ._F .center_crop_image_tensor (self , output_size = output_size )
150+ output = self ._F .center_crop_image_tensor (self . as_subclass ( torch . Tensor ) , output_size = output_size )
151151 return Image .wrap_like (self , output )
152152
153153 def resized_crop (
@@ -161,7 +161,14 @@ def resized_crop(
161161 antialias : bool = False ,
162162 ) -> Image :
163163 output = self ._F .resized_crop_image_tensor (
164- self , top , left , height , width , size = list (size ), interpolation = interpolation , antialias = antialias
164+ self .as_subclass (torch .Tensor ),
165+ top ,
166+ left ,
167+ height ,
168+ width ,
169+ size = list (size ),
170+ interpolation = interpolation ,
171+ antialias = antialias ,
165172 )
166173 return Image .wrap_like (self , output )
167174
@@ -171,7 +178,7 @@ def pad(
171178 fill : FillTypeJIT = None ,
172179 padding_mode : str = "constant" ,
173180 ) -> Image :
174- output = self ._F .pad_image_tensor (self , padding , fill = fill , padding_mode = padding_mode )
181+ output = self ._F .pad_image_tensor (self . as_subclass ( torch . Tensor ) , padding , fill = fill , padding_mode = padding_mode )
175182 return Image .wrap_like (self , output )
176183
177184 def rotate (
@@ -182,8 +189,8 @@ def rotate(
182189 fill : FillTypeJIT = None ,
183190 center : Optional [List [float ]] = None ,
184191 ) -> Image :
185- output = self ._F ._geometry . rotate_image_tensor (
186- self , angle , interpolation = interpolation , expand = expand , fill = fill , center = center
192+ output = self ._F .rotate_image_tensor (
193+ self . as_subclass ( torch . Tensor ) , angle , interpolation = interpolation , expand = expand , fill = fill , center = center
187194 )
188195 return Image .wrap_like (self , output )
189196
@@ -197,8 +204,8 @@ def affine(
197204 fill : FillTypeJIT = None ,
198205 center : Optional [List [float ]] = None ,
199206 ) -> Image :
200- output = self ._F ._geometry . affine_image_tensor (
201- self ,
207+ output = self ._F .affine_image_tensor (
208+ self . as_subclass ( torch . Tensor ) ,
202209 angle ,
203210 translate = translate ,
204211 scale = scale ,
@@ -215,8 +222,8 @@ def perspective(
215222 interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
216223 fill : FillTypeJIT = None ,
217224 ) -> Image :
218- output = self ._F ._geometry . perspective_image_tensor (
219- self , perspective_coeffs , interpolation = interpolation , fill = fill
225+ output = self ._F .perspective_image_tensor (
226+ self . as_subclass ( torch . Tensor ) , perspective_coeffs , interpolation = interpolation , fill = fill
220227 )
221228 return Image .wrap_like (self , output )
222229
@@ -226,55 +233,65 @@ def elastic(
226233 interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
227234 fill : FillTypeJIT = None ,
228235 ) -> Image :
229- output = self ._F ._geometry .elastic_image_tensor (self , displacement , interpolation = interpolation , fill = fill )
236+ output = self ._F .elastic_image_tensor (
237+ self .as_subclass (torch .Tensor ), displacement , interpolation = interpolation , fill = fill
238+ )
230239 return Image .wrap_like (self , output )
231240
232241 def adjust_brightness (self , brightness_factor : float ) -> Image :
233- output = self ._F .adjust_brightness_image_tensor (self , brightness_factor = brightness_factor )
242+ output = self ._F .adjust_brightness_image_tensor (
243+ self .as_subclass (torch .Tensor ), brightness_factor = brightness_factor
244+ )
234245 return Image .wrap_like (self , output )
235246
236247 def adjust_saturation (self , saturation_factor : float ) -> Image :
237- output = self ._F .adjust_saturation_image_tensor (self , saturation_factor = saturation_factor )
248+ output = self ._F .adjust_saturation_image_tensor (
249+ self .as_subclass (torch .Tensor ), saturation_factor = saturation_factor
250+ )
238251 return Image .wrap_like (self , output )
239252
240253 def adjust_contrast (self , contrast_factor : float ) -> Image :
241- output = self ._F .adjust_contrast_image_tensor (self , contrast_factor = contrast_factor )
254+ output = self ._F .adjust_contrast_image_tensor (self . as_subclass ( torch . Tensor ) , contrast_factor = contrast_factor )
242255 return Image .wrap_like (self , output )
243256
244257 def adjust_sharpness (self , sharpness_factor : float ) -> Image :
245- output = self ._F .adjust_sharpness_image_tensor (self , sharpness_factor = sharpness_factor )
258+ output = self ._F .adjust_sharpness_image_tensor (
259+ self .as_subclass (torch .Tensor ), sharpness_factor = sharpness_factor
260+ )
246261 return Image .wrap_like (self , output )
247262
248263 def adjust_hue (self , hue_factor : float ) -> Image :
249- output = self ._F .adjust_hue_image_tensor (self , hue_factor = hue_factor )
264+ output = self ._F .adjust_hue_image_tensor (self . as_subclass ( torch . Tensor ) , hue_factor = hue_factor )
250265 return Image .wrap_like (self , output )
251266
252267 def adjust_gamma (self , gamma : float , gain : float = 1 ) -> Image :
253- output = self ._F .adjust_gamma_image_tensor (self , gamma = gamma , gain = gain )
268+ output = self ._F .adjust_gamma_image_tensor (self . as_subclass ( torch . Tensor ) , gamma = gamma , gain = gain )
254269 return Image .wrap_like (self , output )
255270
256271 def posterize (self , bits : int ) -> Image :
257- output = self ._F .posterize_image_tensor (self , bits = bits )
272+ output = self ._F .posterize_image_tensor (self . as_subclass ( torch . Tensor ) , bits = bits )
258273 return Image .wrap_like (self , output )
259274
260275 def solarize (self , threshold : float ) -> Image :
261- output = self ._F .solarize_image_tensor (self , threshold = threshold )
276+ output = self ._F .solarize_image_tensor (self . as_subclass ( torch . Tensor ) , threshold = threshold )
262277 return Image .wrap_like (self , output )
263278
264279 def autocontrast (self ) -> Image :
265- output = self ._F .autocontrast_image_tensor (self )
280+ output = self ._F .autocontrast_image_tensor (self . as_subclass ( torch . Tensor ) )
266281 return Image .wrap_like (self , output )
267282
268283 def equalize (self ) -> Image :
269- output = self ._F .equalize_image_tensor (self )
284+ output = self ._F .equalize_image_tensor (self . as_subclass ( torch . Tensor ) )
270285 return Image .wrap_like (self , output )
271286
272287 def invert (self ) -> Image :
273- output = self ._F .invert_image_tensor (self )
288+ output = self ._F .invert_image_tensor (self . as_subclass ( torch . Tensor ) )
274289 return Image .wrap_like (self , output )
275290
276291 def gaussian_blur (self , kernel_size : List [int ], sigma : Optional [List [float ]] = None ) -> Image :
277- output = self ._F .gaussian_blur_image_tensor (self , kernel_size = kernel_size , sigma = sigma )
292+ output = self ._F .gaussian_blur_image_tensor (
293+ self .as_subclass (torch .Tensor ), kernel_size = kernel_size , sigma = sigma
294+ )
278295 return Image .wrap_like (self , output )
279296
280297
0 commit comments