@@ -338,30 +338,9 @@ def normalize(tensor: Tensor, mean: List[float], std: List[float], inplace: bool
338
338
if not torch .jit .is_scripting () and not torch .jit .is_tracing ():
339
339
_log_api_usage_once (normalize )
340
340
if not isinstance (tensor , torch .Tensor ):
341
- raise TypeError (f"Input tensor should be a torch tensor . Got { type (tensor )} . " )
341
+ raise TypeError (f"img should be Tensor Image . Got { type (tensor )} " )
342
342
343
- if not tensor .is_floating_point ():
344
- raise TypeError (f"Input tensor should be a float tensor. Got { tensor .dtype } ." )
345
-
346
- if tensor .ndim < 3 :
347
- raise ValueError (
348
- f"Expected tensor to be a tensor image of size (..., C, H, W). Got tensor.size() = { tensor .size ()} "
349
- )
350
-
351
- if not inplace :
352
- tensor = tensor .clone ()
353
-
354
- dtype = tensor .dtype
355
- mean = torch .as_tensor (mean , dtype = dtype , device = tensor .device )
356
- std = torch .as_tensor (std , dtype = dtype , device = tensor .device )
357
- if (std == 0 ).any ():
358
- raise ValueError (f"std evaluated to zero after conversion to { dtype } , leading to division by zero." )
359
- if mean .ndim == 1 :
360
- mean = mean .view (- 1 , 1 , 1 )
361
- if std .ndim == 1 :
362
- std = std .view (- 1 , 1 , 1 )
363
- tensor .sub_ (mean ).div_ (std )
364
- return tensor
343
+ return F_t .normalize (tensor , mean = mean , std = std , inplace = inplace )
365
344
366
345
367
346
def resize (
@@ -1281,11 +1260,7 @@ def erase(img: Tensor, i: int, j: int, h: int, w: int, v: Tensor, inplace: bool
1281
1260
if not isinstance (img , torch .Tensor ):
1282
1261
raise TypeError (f"img should be Tensor Image. Got { type (img )} " )
1283
1262
1284
- if not inplace :
1285
- img = img .clone ()
1286
-
1287
- img [..., i : i + h , j : j + w ] = v
1288
- return img
1263
+ return F_t .erase (img , i , j , h , w , v , inplace = inplace )
1289
1264
1290
1265
1291
1266
def gaussian_blur (img : Tensor , kernel_size : List [int ], sigma : Optional [List [float ]] = None ) -> Tensor :
0 commit comments