def Patch(X, pw, ph): Xt = [] for x in X: w, h = x.shape[:2] i = py_rng.randint(0, w-pw) j = py_rng.randint(0, h-ph) Xt.append(x[i:i+pw, j:j+pw]) return Xt
def Patch(X, pw, ph): Xt = [] for x in X: w, h = x.shape[:2] i = py_rng.randint(0, w - pw) j = py_rng.randint(0, h - ph) Xt.append(x[i:i + pw, j:j + pw]) return Xt
def ColorShift(X, p=1 / 3., scale=20): Xt = [] for x in X: x = x.astype(np.int16) x[:, :, 0] += (py_rng.random() < p) * py_rng.randint(-scale, scale) x[:, :, 1] += (py_rng.random() < p) * py_rng.randint(-scale, scale) x[:, :, 2] += (py_rng.random() < p) * py_rng.randint(-scale, scale) x = np.clip(x, 0, 255).astype(np.uint8) Xt.append(x) return Xt
def ColorShift(X, p=1/3., scale=20): Xt = [] for x in X: x = x.astype(np.int16) x[:, :, 0] += (py_rng.random() < p)*py_rng.randint(-scale, scale) x[:, :, 1] += (py_rng.random() < p)*py_rng.randint(-scale, scale) x[:, :, 2] += (py_rng.random() < p)*py_rng.randint(-scale, scale) x = np.clip(x, 0, 255).astype(np.uint8) Xt.append(x) return Xt
def SeqPatch(X, p_size): Xt = [] for x in X: l = len(x) n = int(p_size * l) i = py_rng.randint(0, l - n) Xt.append(x[i:i + n]) return Xt
def SeqPatch(X, p_size): Xt = [] for x in X: l = len(x) n = int(p_size*l) i = py_rng.randint(0, l-n) Xt.append(x[i:i+n]) return Xt
def Rot90(X): Xt = [] for x in X: x = np.rot90(x, py_rng.randint(0, 3)) Xt.append(x) return Xt