Emotion Recognition
BiWAKO.FerPlus
Emotion prediction model.
The model requires the input image to be trimmed around the face. Use YuNet to detect the face and crop the image around it.
Attributes:
Name | Type | Description |
---|---|---|
model_path |
str |
Path to the model weights. If automatic download is triggered, this path is used to save the model. |
session |
onnxruntime.InferenceSession |
The inference session. |
input_name |
str |
The name of the input node. |
output_name |
str |
The name of the output node. |
emotion_table |
list |
A list of emotions trained. |
__init__(self, model='ferplus8')
special
Initialize the model.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
model |
str |
The name of the model. Also accept the path to the onnx file. If not found, the model will be downloaded. Currently only support "ferplus8". |
'ferplus8' |
predict(self, image)
Return the array of the confidences of each predction.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
image |
Image |
Image to be processed. Accept the path to the image or cv2 image. |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
The array of the confidences of each predction. |
render(self, prediction, image, *args, **kwargs)
Return the list of emotions and their confidences in string over the image.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
prediction |
np.ndarray |
The array of the confidences of each predction. |
required |
image |
Image |
Image to be processed. Accept the path to the image or cv2 image. Not actually required. |
required |
Returns:
Type | Description |
---|---|
np.ndarray |
Image with the list of emotions and their confidences in string. |