Ejemplo n.º 1
0
Archivo: tta.py Proyecto: xyuan/mlcomp
    def inverse(self, a: np.array):
        last_dim = len(a.shape) - 1
        for t in self.tfms:
            if isinstance(t, A.HorizontalFlip):
                a = flip(a, last_dim)
            elif isinstance(t, A.VerticalFlip):
                a = flip(a, last_dim - 1)
            elif isinstance(t, A.Transpose):
                axis = (0, 1, 3, 2) if len(a.shape) == 4 else (0, 2, 1)
                a = a.permute(*axis)

        return a
Ejemplo n.º 2
0
def to_rgb(batch: np.array) -> np.array:
    batch = batch.permute(0, 2, 3, 1).numpy() if len(
        batch.shape) == 4 else batch.permute(0, 2, 3, 4, 1).numpy()
    batch = (batch + 1) / 2
    batch = (batch * 255).astype(np.uint8)
    return batch
Ejemplo n.º 3
0
def to_rgb(batch: np.array) -> np.array:
    batch = (batch.permute(0, 2, 3, 1).numpy() + 1) / 2
    batch = (batch * 255).astype(np.uint8)
    return batch