From 63d8126a674b8c3f0adf6ebc978832f548f757ca Mon Sep 17 00:00:00 2001 From: natanielruiz <nataniel777@hotmail.com> Date: 星期六, 23 九月 2017 02:43:56 +0800 Subject: [PATCH] next --- code/datasets.py | 30 ++++++++++-------------------- 1 files changed, 10 insertions(+), 20 deletions(-) diff --git a/code/datasets.py b/code/datasets.py index 6f1f1ff..da0603f 100644 --- a/code/datasets.py +++ b/code/datasets.py @@ -38,7 +38,9 @@ x_max = max(pt2d[0,:]) y_max = max(pt2d[1,:]) - k = 0.35 + # k = 0.35 was being used beforehand + # k = 0.2 to 0.40 + k = np.random.random_sample() * 0.2 + 0.2 x_min -= 0.6 * k * abs(x_max - x_min) y_min -= 2 * k * abs(y_max - y_min) x_max += 0.6 * k * abs(x_max - x_min) @@ -59,15 +61,10 @@ roll = -roll img = img.transpose(Image.FLIP_LEFT_RIGHT) - # Rotate? - # rnd = np.random.random_sample() - # if rnd < 0.5: - # if roll >= 0: - # img = img.rotate(30) - # roll -= 30 - # else: - # img = img.rotate(-30) - # roll += 30 + # Blur? + rnd = np.random.random_sample() + if rnd < 0.05: + img = img.filter(ImageFilter.BLUR) # Bin values bins = np.array(range(-99, 102, 3)) @@ -82,7 +79,7 @@ if self.transform is not None: img = self.transform(img) - return img, labels, cont_labels, elf.X_train[index] + return img, labels, cont_labels, self.X_train[index] def __len__(self): # 122,450 @@ -281,7 +278,7 @@ yaw, pitch, roll = [float(line[1]), float(line[2]), float(line[3])] # Crop the face - k = 0.40 + k = 0.32 x1 = float(line[4]) y1 = float(line[5]) x2 = float(line[6]) @@ -356,7 +353,7 @@ R = R[:3,:] pose_annot.close() - roll = np.arctan2(R[1][0], R[0][0]) * 180 / np.pi + roll = -np.arctan2(R[1][0], R[0][0]) * 180 / np.pi yaw = np.arctan2(-R[2][0], np.sqrt(R[2][1] ** 2 + R[2][2] ** 2)) * 180 / np.pi pitch = -np.arctan2(R[2][1], R[2][2]) * 180 / np.pi @@ -367,13 +364,6 @@ x_max += 0.6 * k * abs(x_max - x_min) y_max += 0.6 * k * abs(y_max - y_min) img = img.crop((int(x_min), int(y_min), int(x_max), int(y_max))) - - # Flip? - # rnd = np.random.random_sample() - # if rnd < 0.5: - # yaw = -yaw - # roll = -roll - # img = img.transpose(Image.FLIP_LEFT_RIGHT) # Bin values bins = np.array(range(-99, 102, 3)) -- Gitblit v1.8.0