@@ -16,7 +16,7 @@ def __new__(
16
16
device : Optional [Union [torch .device , str , int ]] = None ,
17
17
requires_grad : bool = False ,
18
18
) -> F :
19
- feature = cast (
19
+ return cast (
20
20
F ,
21
21
torch .Tensor ._make_subclass (
22
22
cast (_TensorBase , cls ),
@@ -25,13 +25,6 @@ def __new__(
25
25
),
26
26
)
27
27
28
- # To avoid circular dependency between features and transforms
29
- # This does not work with dataloader multi-worker setup
30
- # from torchvision.prototype.transforms import functional
31
- # setattr(feature, "_F", functional) # type: ignore[attr-defined]
32
-
33
- return feature
34
-
35
28
@classmethod
36
29
def new_like (
37
30
cls : Type [F ],
@@ -92,34 +85,26 @@ def __torch_function__(
92
85
return output
93
86
94
87
def horizontal_flip (self ) -> Any :
95
- # Just output itself
96
- # How dangerous to do this instead of raising an error ?
97
88
return self
98
89
99
90
def vertical_flip (self ) -> Any :
100
- # Just output itself
101
- # How dangerous to do this instead of raising an error ?
102
91
return self
103
92
93
+ # TODO: We have to ignore override mypy error as there is torch.Tensor built-in deprecated op: Tensor.resize
94
+ # https://github.com/pytorch/pytorch/blob/e8727994eb7cdb2ab642749d6549bc497563aa06/torch/_tensor.py#L588-L593
104
95
def resize ( # type: ignore[override]
105
96
self ,
106
97
size : List [int ],
107
98
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
108
99
max_size : Optional [int ] = None ,
109
100
antialias : bool = False ,
110
101
) -> Any :
111
- # Just output itself
112
- # How dangerous to do this instead of raising an error ?
113
102
return self
114
103
115
104
def crop (self , top : int , left : int , height : int , width : int ) -> Any :
116
- # Just output itself
117
- # How dangerous to do this instead of raising an error ?
118
105
return self
119
106
120
107
def center_crop (self , output_size : List [int ]) -> Any :
121
- # Just output itself
122
- # How dangerous to do this instead of raising an error ?
123
108
return self
124
109
125
110
def resized_crop (
@@ -132,13 +117,9 @@ def resized_crop(
132
117
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
133
118
antialias : bool = False ,
134
119
) -> Any :
135
- # Just output itself
136
- # How dangerous to do this instead of raising an error ?
137
120
return self
138
121
139
122
def pad (self , padding : List [int ], fill : Union [float , Sequence [float ]] = 0 , padding_mode : str = "constant" ) -> Any :
140
- # Just output itself
141
- # How dangerous to do this instead of raising an error ?
142
123
return self
143
124
144
125
def rotate (
@@ -149,8 +130,6 @@ def rotate(
149
130
fill : Optional [List [float ]] = None ,
150
131
center : Optional [List [float ]] = None ,
151
132
) -> Any :
152
- # Just output itself
153
- # How dangerous to do this instead of raising an error ?
154
133
return self
155
134
156
135
def affine (
@@ -163,8 +142,6 @@ def affine(
163
142
fill : Optional [List [float ]] = None ,
164
143
center : Optional [List [float ]] = None ,
165
144
) -> Any :
166
- # Just output itself
167
- # How dangerous to do this instead of raising an error ?
168
145
return self
169
146
170
147
def perspective (
@@ -173,76 +150,46 @@ def perspective(
173
150
interpolation : InterpolationMode = InterpolationMode .BILINEAR ,
174
151
fill : Optional [List [float ]] = None ,
175
152
) -> Any :
176
- # Just output itself
177
- # How dangerous to do this instead of raising an error ?
178
153
return self
179
154
180
155
def adjust_brightness (self , brightness_factor : float ) -> Any :
181
- # Just output itself
182
- # How dangerous to do this instead of raising an error ?
183
156
return self
184
157
185
158
def adjust_saturation (self , saturation_factor : float ) -> Any :
186
- # Just output itself
187
- # How dangerous to do this instead of raising an error ?
188
159
return self
189
160
190
161
def adjust_contrast (self , contrast_factor : float ) -> Any :
191
- # Just output itself
192
- # How dangerous to do this instead of raising an error ?
193
162
return self
194
163
195
164
def adjust_sharpness (self , sharpness_factor : float ) -> Any :
196
- # Just output itself
197
- # How dangerous to do this instead of raising an error ?
198
165
return self
199
166
200
167
def adjust_hue (self , hue_factor : float ) -> Any :
201
- # Just output itself
202
- # How dangerous to do this instead of raising an error ?
203
168
return self
204
169
205
170
def adjust_gamma (self , gamma : float , gain : float = 1 ) -> Any :
206
- # Just output itself
207
- # How dangerous to do this instead of raising an error ?
208
171
return self
209
172
210
173
def posterize (self , bits : int ) -> Any :
211
- # Just output itself
212
- # How dangerous to do this instead of raising an error ?
213
174
return self
214
175
215
176
def solarize (self , threshold : float ) -> Any :
216
- # Just output itself
217
- # How dangerous to do this instead of raising an error ?
218
177
return self
219
178
220
179
def autocontrast (self ) -> Any :
221
- # Just output itself
222
- # How dangerous to do this instead of raising an error ?
223
180
return self
224
181
225
182
def equalize (self ) -> Any :
226
- # Just output itself
227
- # How dangerous to do this instead of raising an error ?
228
183
return self
229
184
230
185
def invert (self ) -> Any :
231
- # Just output itself
232
- # How dangerous to do this instead of raising an error ?
233
186
return self
234
187
235
188
def erase (self , i : int , j : int , h : int , w : int , v : torch .Tensor ) -> Any :
236
- # Just output itself
237
- # How dangerous to do this instead of raising an error ?
238
189
return self
239
190
240
191
def mixup (self , lam : float ) -> Any :
241
- # Just output itself
242
- # How dangerous to do this instead of raising an error ?
243
192
return self
244
193
245
194
def cutmix (self , box : Tuple [int , int , int , int ], lam_adjusted : float ) -> Any :
246
- # Just output itself
247
- # How dangerous to do this instead of raising an error ?
248
195
return self
0 commit comments