def transform_train(self, img, *targets): for idim in range(len(self.dims)): if _np.random.random() < 0.5: img = _u.flipany(img, self.dims[idim]) if self.tgtdims is not None: targets = [ _u.flipany(t, self.tgtdims[idim]) for t in targets ] return img, targets
def transform_pred(self, img, i, fast): assert i < self.npreds(fast), "This should never happen, please file an issue." for idim, d in enumerate(self.dims): if i >> idim & 1: img = _u.flipany(img, d) return img
def transform_pred(self, img, i, fast): assert i < self.npreds( fast), "This should never happen, please file an issue." for idim, d in enumerate(self.dims): if i >> idim & 1: img = _u.flipany(img, d) return img
def flipped_classes(X, y, n, le, old, new): """ Horizontally flips all images in `X` which are labeled as `old` and label them as `new`. Returns the flipped X, y, n. """ indices = np.where(y == le.transform(old))[0] return (flipany(X[indices], dim=3), np.full(len(indices), le.transform(new), dtype=y.dtype), tuple(n[i] for i in indices))
def flipped_classes(X, y, n, le, old, new): """ Horizontally flips all images in `X` which are labeled as `old` and label them as `new`. Returns the flipped X, y, n. """ indices = np.where(y == le.transform(old))[0] return ( flipany(X[indices], dim=3), np.full(len(indices), le.transform(new), dtype=y.dtype), tuple(n[i] for i in indices) )
def flipall_images(images): """ Horizontally flips all given `images`, assuming `images` to be a list of HWC tensors. """ return [flipany(img, dim=1) for img in images]
def flipped(X, y, n, old, new): indices = np.where(y == old)[0] return flipany(X[indices], dim=3), np.full(len(indices), new, dtype=y.dtype), [n[i] for i in indices]
def transform_train(self, img, *targets): for d in self.dims: if _np.random.random() < 0.5: img = _u.flipany(img, d) return img, targets