feat: visual emotion recognition agent #54
@@ -6,23 +6,27 @@ import cv2
|
||||
import numpy as np
|
||||
import zmq
|
||||
import zmq.asyncio as azmq
|
||||
from control_backend.agents.perception.visual_emotion_recognition_agentvisual_emotion_recognizer import ( # noqa
|
||||
DeepFaceEmotionRecognizer,
|
||||
)
|
||||
from pydantic_core import ValidationError
|
||||
|
||||
from control_backend.agents import BaseAgent
|
||||
from control_backend.agents.perception.visual_emotion_recognition_agent.visual_emotion_recognizer import ( # noqa
|
||||
DeepFaceEmotionRecognizer,
|
||||
)
|
||||
from control_backend.core.agent_system import InternalMessage
|
||||
from control_backend.core.config import settings
|
||||
from control_backend.schemas.belief_message import Belief
|
||||
|
||||
|
||||
class VisualEmotionRecognitionAgent(BaseAgent):
|
||||
def __init__(self, name: str, socket_address: str, bind: bool = False, timeout_ms: int = 1000,
|
||||
window_duration:
|
||||
int = settings.behaviour_settings.visual_emotion_recognition_window_duration_s
|
||||
, min_frames_required: int =
|
||||
settings.behaviour_settings.visual_emotion_recognition_min_frames_per_face):
|
||||
def __init__(
|
||||
self,
|
||||
name: str,
|
||||
socket_address: str,
|
||||
bind: bool = False,
|
||||
timeout_ms: int = 1000,
|
||||
window_duration: int = settings.behaviour_settings.visual_emotion_recognition_window_duration_s, # noqa
|
||||
min_frames_required: int = settings.behaviour_settings.visual_emotion_recognition_min_frames_per_face, # noqa
|
||||
):
|
||||
"""
|
||||
Initialize the Visual Emotion Recognition Agent.
|
||||
|
||||
@@ -135,8 +139,9 @@ class VisualEmotionRecognitionAgent(BaseAgent):
|
||||
for emotion in emotions_to_remove:
|
||||
self.logger.info(f"Emotion '{emotion}' has disappeared.")
|
||||
try:
|
||||
emotion_beliefs_remove.append(Belief(name="emotion_detected", arguments=[emotion],
|
||||
remove=True))
|
||||
emotion_beliefs_remove.append(
|
||||
Belief(name="emotion_detected", arguments=[emotion], remove=True)
|
||||
)
|
||||
except ValidationError:
|
||||
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user