From f111cb002b9c6065fdf6bb274ce5857a9e875e8c Mon Sep 17 00:00:00 2001 From: chenshijun <csj_sky@126.com> Date: 星期三, 05 六月 2019 15:38:49 +0800 Subject: [PATCH] face rectangle --- code/datasets.py | 15 ++++----------- 1 files changed, 4 insertions(+), 11 deletions(-) diff --git a/code/datasets.py b/code/datasets.py index 5f1dfdc..e8ab9f4 100644 --- a/code/datasets.py +++ b/code/datasets.py @@ -96,7 +96,6 @@ img = Image.open(os.path.join(self.data_dir, self.X_train[index] + self.img_ext)) img = img.convert(self.image_mode) mat_path = os.path.join(self.data_dir, self.y_train[index] + self.annot_ext) - shape_path = os.path.join(self.data_dir, self.y_train[index] + '_shape.npy') # Crop the face loosely pt2d = utils.get_pt2d_from_mat(mat_path) @@ -136,11 +135,8 @@ bins = np.array(range(-99, 102, 3)) binned_pose = np.digitize([yaw, pitch, roll], bins) - 1 - # Get shape - shape = np.load(shape_path) - # Get target tensors - labels = torch.LongTensor(np.concatenate((binned_pose, shape), axis = 0)) + labels = binned_pose cont_labels = torch.FloatTensor([yaw, pitch, roll]) if self.transform is not None: @@ -171,7 +167,6 @@ img = Image.open(os.path.join(self.data_dir, self.X_train[index] + self.img_ext)) img = img.convert(self.image_mode) mat_path = os.path.join(self.data_dir, self.y_train[index] + self.annot_ext) - shape_path = os.path.join(self.data_dir, self.y_train[index] + '_shape.npy') # Crop the face loosely pt2d = utils.get_pt2d_from_mat(mat_path) @@ -189,7 +184,8 @@ img = img.crop((int(x_min), int(y_min), int(x_max), int(y_max))) # We get the pose in radians - pose = utils.get_ypr_fro # Head pose from AFLW2000 datasetp.pi + pose = utils.get_ypr_from_mat(mat_path) + pitch = pose[0] * 180 / np.pi yaw = pose[1] * 180 / np.pi roll = pose[2] * 180 / np.pi @@ -214,11 +210,8 @@ bins = np.array(range(-99, 102, 3)) binned_pose = np.digitize([yaw, pitch, roll], bins) - 1 - # Get shape - shape = np.load(shape_path) - # Get target tensors - labels = torch.LongTensor(np.concatenate((binned_pose, shape), axis = 0)) + labels = binned_pose cont_labels = torch.FloatTensor([yaw, pitch, roll]) if self.transform is not None: -- Gitblit v1.8.0