Nataniel Ruiz
2019-03-04 67b572c773e69c769be6fb08b27b35b18c0cbbdb
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: