@@ -117,17 +117,17 @@ def to_color_space(self, color_space: Union[str, ColorSpace], copy: bool = True)
117
117
return Image .wrap_like (
118
118
self ,
119
119
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
121
121
),
122
122
color_space = color_space ,
123
123
)
124
124
125
125
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 ) )
127
127
return Image .wrap_like (self , output )
128
128
129
129
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 ) )
131
131
return Image .wrap_like (self , output )
132
132
133
133
def resize ( # type: ignore[override]
@@ -138,16 +138,16 @@ def resize( # type: ignore[override]
138
138
antialias : bool = False ,
139
139
) -> Image :
140
140
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
142
142
)
143
143
return Image .wrap_like (self , output )
144
144
145
145
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 )
147
147
return Image .wrap_like (self , output )
148
148
149
149
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 )
151
151
return Image .wrap_like (self , output )
152
152
153
153
def resized_crop (
@@ -161,7 +161,14 @@ def resized_crop(
161
161
antialias : bool = False ,
162
162
) -> Image :
163
163
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 ,
165
172
)
166
173
return Image .wrap_like (self , output )
167
174
@@ -171,7 +178,7 @@ def pad(
171
178
fill : FillTypeJIT = None ,
172
179
padding_mode : str = "constant" ,
173
180
) -> 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 )
175
182
return Image .wrap_like (self , output )
176
183
177
184
def rotate (
@@ -182,8 +189,8 @@ def rotate(
182
189
fill : FillTypeJIT = None ,
183
190
center : Optional [List [float ]] = None ,
184
191
) -> 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
187
194
)
188
195
return Image .wrap_like (self , output )
189
196
@@ -197,8 +204,8 @@ def affine(
197
204
fill : FillTypeJIT = None ,
198
205
center : Optional [List [float ]] = None ,
199
206
) -> Image :
200
- output = self ._F ._geometry . affine_image_tensor (
201
- self ,
207
+ output = self ._F .affine_image_tensor (
208
+ self . as_subclass ( torch . Tensor ) ,
202
209
angle ,
203
210
translate = translate ,
204
211
scale = scale ,
@@ -215,8 +222,8 @@ def perspective(
215
222
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
216
223
fill : FillTypeJIT = None ,
217
224
) -> 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
220
227
)
221
228
return Image .wrap_like (self , output )
222
229
@@ -226,55 +233,65 @@ def elastic(
226
233
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
227
234
fill : FillTypeJIT = None ,
228
235
) -> 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
+ )
230
239
return Image .wrap_like (self , output )
231
240
232
241
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
+ )
234
245
return Image .wrap_like (self , output )
235
246
236
247
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
+ )
238
251
return Image .wrap_like (self , output )
239
252
240
253
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 )
242
255
return Image .wrap_like (self , output )
243
256
244
257
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
+ )
246
261
return Image .wrap_like (self , output )
247
262
248
263
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 )
250
265
return Image .wrap_like (self , output )
251
266
252
267
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 )
254
269
return Image .wrap_like (self , output )
255
270
256
271
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 )
258
273
return Image .wrap_like (self , output )
259
274
260
275
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 )
262
277
return Image .wrap_like (self , output )
263
278
264
279
def autocontrast (self ) -> Image :
265
- output = self ._F .autocontrast_image_tensor (self )
280
+ output = self ._F .autocontrast_image_tensor (self . as_subclass ( torch . Tensor ) )
266
281
return Image .wrap_like (self , output )
267
282
268
283
def equalize (self ) -> Image :
269
- output = self ._F .equalize_image_tensor (self )
284
+ output = self ._F .equalize_image_tensor (self . as_subclass ( torch . Tensor ) )
270
285
return Image .wrap_like (self , output )
271
286
272
287
def invert (self ) -> Image :
273
- output = self ._F .invert_image_tensor (self )
288
+ output = self ._F .invert_image_tensor (self . as_subclass ( torch . Tensor ) )
274
289
return Image .wrap_like (self , output )
275
290
276
291
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
+ )
278
295
return Image .wrap_like (self , output )
279
296
280
297
0 commit comments