Browse Source

[to #42322933]update fer to satisfy demo service requirements

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10357094
master
ly261666 yingda.chen 3 years ago
parent
commit
2bfdbbc9d0
3 changed files with 7 additions and 7 deletions
  1. +2
    -0
      modelscope/models/cv/face_detection/mogface/models/detectors.py
  2. +4
    -1
      modelscope/pipelines/cv/facial_expression_recognition_pipeline.py
  3. +1
    -6
      modelscope/utils/cv/image_utils.py

+ 2
- 0
modelscope/models/cv/face_detection/mogface/models/detectors.py View File

@@ -1,3 +1,5 @@
# The implementation is based on MogFace, available at
# https://github.com/damo-cv/MogFace
import os

import cv2


+ 4
- 1
modelscope/pipelines/cv/facial_expression_recognition_pipeline.py View File

@@ -45,6 +45,9 @@ class FacialExpressionRecognitionPipeline(Pipeline):

# face detect pipeline
det_model_id = 'damo/cv_resnet_facedetection_scrfd10gkps'
self.map_list = [
'Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral'
]
self.face_detection = pipeline(
Tasks.face_detection, model=det_model_id)

@@ -122,7 +125,7 @@ class FacialExpressionRecognitionPipeline(Pipeline):
labels = result[1].tolist()
return {
OutputKeys.SCORES: scores,
OutputKeys.LABELS: labels,
OutputKeys.LABELS: self.map_list[labels]
}

def postprocess(self, inputs: Dict[str, Any]) -> Dict[str, Any]:


+ 1
- 6
modelscope/utils/cv/image_utils.py View File

@@ -113,12 +113,7 @@ def draw_face_detection_no_lm_result(img_path, detection_result):


def draw_facial_expression_result(img_path, facial_expression_result):
label_idx = facial_expression_result[OutputKeys.LABELS]
map_list = [
'Angry', 'Disgust', 'Fear', 'Happy', 'Sad', 'Surprise', 'Neutral'
]
label = map_list[label_idx]

label = facial_expression_result[OutputKeys.LABELS]
img = cv2.imread(img_path)
assert img is not None, f"Can't read img: {img_path}"
cv2.putText(


Loading…
Cancel
Save