-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Integrate emotions recognition #51
base: main
Are you sure you want to change the base?
Conversation
face_emotions = [] | ||
boxes = [] | ||
frame_height, frame_width, _ = frame.shape | ||
for face_box in faces.boxes: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
faces.boxes
reference is not safe since faces
can be None
. This function should return Result | None
and perform a check on faces
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Btw, predict
method should take not-none arguments. You can rename this method to __predict_safe
and use it in stream
and predict_batch
.
emotions: list[float] | ||
boxes: list[FloatArray2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We could stack these results and store them as np.ndarray
s instead of lists. We do so in other Result
s in general
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's no use duplicating face.Result
as boxes
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is - that way there is no coupling between emotion recognition and face detection in the visualization layer.
Duplicating it is almost free (the cost of doing that is negligible), but it's much easier to handle it that way in the visualization layer.
class Result: | ||
emotions: list[float] | ||
boxes: list[FloatArray2] | ||
|
||
def __init__(self, emotions: list[float], boxes: list[FloatArray2]) -> None: | ||
self.emotions = emotions | ||
self.boxes = boxes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be a frozen dataclass
scores = { | ||
'angry': -0.05, | ||
'disgust': 0, | ||
'fear': -0.07, | ||
'happy': 1, | ||
'sad': -1, | ||
'surprise': 0, | ||
'neutral': 0, | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dict shouldn't be located here since it is going to be created on each call 💀 Please make it a private constant
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this in mind - how about making this dict injected into an Estimator
via constructor?
emotions: list[float] | ||
boxes: list[FloatArray2] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, it's no use duplicating face.Result
as boxes
here
Closes #17
Changes
task.emotion.Estimator
allows estimating emotional "score" of an actor based on the face detectionvisualization.Visualizer
annotates face bounding boxes with emotion labels