MCPcopy Create free account
hub / github.com/VisionXLab/OF-Diff / augment_img_tensor

Function augment_img_tensor

ldm/modules/image_degradation/utils_image.py:422–438  ·  view source on GitHub ↗

Kai Zhang (github: https://github.com/cszn)

(img, mode=0)

Source from the content-addressed store, hash-verified

420
421
422def augment_img_tensor(img, mode=0):
423 '''Kai Zhang (github: https://github.com/cszn)
424 '''
425 img_size = img.size()
426 img_np = img.data.cpu().numpy()
427 if len(img_size) == 3:
428 img_np = np.transpose(img_np, (1, 2, 0))
429 elif len(img_size) == 4:
430 img_np = np.transpose(img_np, (2, 3, 1, 0))
431 img_np = augment_img(img_np, mode=mode)
432 img_tensor = torch.from_numpy(np.ascontiguousarray(img_np))
433 if len(img_size) == 3:
434 img_tensor = img_tensor.permute(2, 0, 1)
435 elif len(img_size) == 4:
436 img_tensor = img_tensor.permute(3, 2, 0, 1)
437
438 return img_tensor.type_as(img)
439
440
441def augment_img_np3(img, mode=0):

Callers

nothing calls this directly

Calls 1

augment_imgFunction · 0.85

Tested by

no test coverage detected