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

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10357094
This commit is contained in:
ly261666
2022-10-11 22:23:36 +08:00
committed by yingda.chen
parent 69da8f91ac
commit 2bfdbbc9d0
3 changed files with 7 additions and 7 deletions

View File

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

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]:

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(