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