Example #1
0
 def get_mood(self, uid):
     picture_model_service = PictureModelService()
     picture = picture_model_service.find_by_key(uid)
     if picture is not None and picture.mood_process is not None:
         return picture.mood_process
     else:
         return []
Example #2
0
 def get_mood(self, uid):
     picture_model_service = PictureModelService()
     picture = picture_model_service.find_by_key(uid)
     if picture is not None and picture.mood_process is not None:
         return picture.mood_process
     else:
         return []
Example #3
0
    def perfom_mood_detection(self, uid):
        picture_model_service = PictureModelService()
        picture = picture_model_service.find_by_key(uid)
        if picture is None or picture.image_path is None:
            return []

        mood_process = MoodProcess()
        mood_process.startDate = datetime.datetime.utcnow()
        # extract features and landmarks
        feature_landmarks = self.extractor.extract_with_landmark(picture.image_path)
        # for each feature/landmark predict mood and convert landmark to points
        for feature_landmark in feature_landmarks:
            face = Face()
            mood = self.classifier.predict(feature_landmark.features)
            face.mood = const.moods[int(mood[0])]
            face.points = self.convert2points(feature_landmark.landmark)
            mood_process.faces.append(face)
        mood_process.endDate = datetime.datetime.utcnow()

        picture.mood_process = mood_process
        # save picture model
        picture_model_service.save(picture)
        return picture.mood_process
Example #4
0
    def perfom_mood_detection(self, uid):
        picture_model_service = PictureModelService()
        picture = picture_model_service.find_by_key(uid)
        if picture is None or picture.image_path is None:
            return []

        mood_process = MoodProcess()
        mood_process.startDate = datetime.datetime.utcnow()
        # extract features and landmarks
        feature_landmarks = self.extractor.extract_with_landmark(
            picture.image_path)
        # for each feature/landmark predict mood and convert landmark to points
        for feature_landmark in feature_landmarks:
            face = Face()
            mood = self.classifier.predict(feature_landmark.features)
            face.mood = const.moods[int(mood[0])]
            face.points = self.convert2points(feature_landmark.landmark)
            mood_process.faces.append(face)
        mood_process.endDate = datetime.datetime.utcnow()

        picture.mood_process = mood_process
        # save picture model
        picture_model_service.save(picture)
        return picture.mood_process