MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / apply_image

Method apply_image

PATH/core/data/transforms/seg_aug_dev.py:38–54  ·  view source on GitHub ↗

Flip the image(s). Args: img (ndarray): of shape HxW, HxWxC, or NxHxWxC. The array can be of type uint8 in range [0, 255], or floating point in range [0, 1] or [0, 255]. Returns: ndarray: the flipped image(s).

(self, img: np.ndarray)

Source from the content-addressed store, hash-verified

36 self._set_attributes(locals())
37
38 def apply_image(self, img: np.ndarray) -> np.ndarray:
39 """
40 Flip the image(s).
41
42 Args:
43 img (ndarray): of shape HxW, HxWxC, or NxHxWxC. The array can be
44 of type uint8 in range [0, 255], or floating point in range
45 [0, 1] or [0, 255].
46 Returns:
47 ndarray: the flipped image(s).
48 """
49 # NOTE: opencv would be faster:
50 # https://github.com/pytorch/pytorch/issues/16424#issuecomment-580695672
51 if img.ndim <= 3: # HxW, HxWxC
52 return np.flip(img, axis=1)
53 else:
54 return np.flip(img, axis=-2)
55
56 def apply_coords(self, coords: np.ndarray) -> np.ndarray:
57 """

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected