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

Link: https://code.alibaba-inc.com/Ali-MaaS/MaaS-lib/codereview/10372291
This commit is contained in:
ly261666
2022-10-12 15:17:11 +08:00
committed by yingda.chen
parent 800588b8a6
commit 42be514bac
2 changed files with 4 additions and 6 deletions

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

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(