mirror of
https://github.com/modelscope/modelscope.git
synced 2026-07-11 04:50:39 +02:00
[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:
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user