Browse Source

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

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10372291
master
ly261666 yingda.chen 3 years ago
parent
commit
42be514bac
2 changed files with 4 additions and 6 deletions
  1. +1
    -5
      modelscope/pipelines/cv/facial_expression_recognition_pipeline.py
  2. +3
    -1
      modelscope/utils/cv/image_utils.py

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

@@ -122,11 +122,7 @@ class FacialExpressionRecognitionPipeline(Pipeline):
result = self.fer(input)
assert result is not None
scores = result[0].tolist()
labels = result[1].tolist()
return {
OutputKeys.SCORES: scores,
OutputKeys.LABELS: self.map_list[labels]
}
return {OutputKeys.SCORES: scores, OutputKeys.LABELS: self.map_list}

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

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

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


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


Loading…
Cancel
Save