Example #1
0
    def __init__(self, detector, keypoint_estimator, radius=3):
        super(ProbabilisticKeypointPrediction, self).__init__()
        # face detector
        RGB2GRAY = pr.ConvertColorSpace(pr.RGB2GRAY)
        self.detect = pr.Predict(detector, RGB2GRAY, pr.ToBoxes2D(['face']))

        # creating pre-processing pipeline for keypoint estimator
        preprocess = SequentialProcessor()
        preprocess.add(pr.ResizeImage(keypoint_estimator.input_shape[1:3]))
        preprocess.add(pr.ConvertColorSpace(pr.RGB2GRAY))
        preprocess.add(pr.NormalizeImage())
        preprocess.add(pr.ExpandDims(0))
        preprocess.add(pr.ExpandDims(-1))

        # creating post-processing pipeline for keypoint esimtator
        # postprocess = SequentialProcessor()
        # postprocess.add(ToNumpyArray())
        # postprocess.add(pr.Squeeze(1))

        # keypoint estimator predictions
        self.estimate_keypoints = PredictMeanDistribution(
            keypoint_estimator, preprocess)

        # self.estimate_keypoints = pr.Predict(
        # keypoint_estimator, preprocess, postprocess)

        # used for drawing up keypoints in original image
        self.change_coordinates = pr.ChangeKeypointsCoordinateSystem()
        self.denormalize_keypoints = pr.DenormalizeKeypoints()
        self.crop_boxes2D = pr.CropBoxes2D()
        self.num_keypoints = len(keypoint_estimator.output_shape)
        self.draw = pr.DrawKeypoints2D(self.num_keypoints, radius, False)
        self.draw_boxes2D = pr.DrawBoxes2D(['face'], colors=[[0, 255, 0]])
        self.wrap = pr.WrapOutput(['image', 'boxes2D'])
Example #2
0
    def __init__(self, radius=3):
        super(DetectGMMKeypointNet2D, self).__init__()
        self.detect = HaarCascadeFrontalFace(draw=False)
        self.estimate_keypoints = GMMKeypointNet2D(draw=False)
        self.num_keypoints = self.estimate_keypoints.num_keypoints

        self.change_coordinates = pr.ChangeKeypointsCoordinateSystem()
        self.denormalize_keypoints = pr.DenormalizeKeypoints()
        self.crop = pr.CropBoxes2D()
        self.compute_means = ComputeMeans()
        self.draw_keypoints = pr.DrawKeypoints2D(self.num_keypoints, radius)
        self.draw_probabilities = DrawProbabilities(self.num_keypoints)
        self.draw_boxes2D = pr.DrawBoxes2D(['Face'], colors=[[0, 255, 0]])
        outputs = ['image', 'boxes2D', 'keypoints2D', 'contours']
        self.wrap = pr.WrapOutput(outputs)
Example #3
0
 def __init__(self, weights, measure, thresh, eigenfaces,
              mean_face, offsets=[0, 0]):
     super(DetectEigenFaces, self).__init__()
     self.offsets = offsets
     self.class_names = list(weights.keys()) + ['Face not found']
     self.colors = lincolor(len(self.class_names))
     self.croped_images = None
     # detection
     self.detect = HaarCascadeFrontalFace()
     self.square = SequentialProcessor()
     self.square.add(pr.SquareBoxes2D())
     self.square.add(pr.OffsetBoxes2D(offsets))
     self.clip = pr.ClipBoxes2D()
     self.crop = pr.CropBoxes2D()
     self.face_detector = EigenFaceDetector(weights, measure, thresh,
                                            eigenfaces, mean_face)
     # drawing and wrapping
     self.draw = pr.DrawBoxes2D(self.class_names, self.colors,
                                weighted=True, with_score=False)
     self.wrap = pr.WrapOutput(['image', 'boxes2D'])
Example #4
0
File: rock.py Project: oarriaga/paz
    def __init__(self, estimate_pose, offsets, valid_class_names, draw=True):
        super(PIX2POSE_ROCK, self).__init__()
        self.estimate_pose = estimate_pose
        self.object_sizes = self.estimate_pose.object_sizes

        self.postprocess_boxes = SequentialProcessor([
            pr.FilterClassBoxes2D(valid_class_names),
            pr.SquareBoxes2D(),
            pr.OffsetBoxes2D(offsets)
        ])

        self.clip = pr.ClipBoxes2D()
        self.crop = pr.CropBoxes2D()
        self.unwrap = pr.UnwrapDictionary(['pose6D', 'points2D', 'points3D'])
        self.draw_boxes2D = pr.DrawBoxes2D(valid_class_names)
        self.cube_points3D = build_cube_points3D(*self.object_sizes)
        self.draw_pose6D = pr.DrawPose6D(self.cube_points3D,
                                         self.estimate_pose.camera.intrinsics)
        self.draw = draw
        self.wrap = pr.WrapOutput(['image', 'poses6D'])
Example #5
0
 def __init__(self) -> None:
     super(EmotionDetector, self).__init__()
     self.detector = dlib.get_frontal_face_detector()
     self.crop = pr.CropBoxes2D()
     self.classify = MiniXceptionFER()
Example #6
0
 def __init__(self):
     super(CropFrontalFace, self).__init__()
     self.detect = HaarCascadeFrontalFace(draw=False)
     self.crop = pr.CropBoxes2D()