feat: visual emotion recognition agent #54

Merged
s.o.h.luijkx merged 27 commits from feat/visual-emotion-recognition into main 2026-01-30 16:53:16 +00:00
4 changed files with 9 additions and 11 deletions
Showing only changes of commit a09d8b3d9a - Show all commits

View File

@@ -7,7 +7,7 @@ from zmq.asyncio import Context
from control_backend.agents import BaseAgent
from control_backend.agents.actuation.robot_gesture_agent import RobotGestureAgent
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognition_agent import (
from control_backend.agents.perception.visual_emotion_recognition_agent.visual_emotion_recognition_agent import (
VisualEmotionRecognitionAgent,
)
from control_backend.core.config import settings

View File

@@ -9,7 +9,7 @@ import zmq
import zmq.asyncio as azmq
from control_backend.agents import BaseAgent
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognizer import (
from control_backend.agents.perception.visual_emotion_recognition_agent.visual_emotion_recognizer import (
DeepFaceEmotionRecognizer,
)
from control_backend.core.agent_system import InternalMessage
@@ -105,11 +105,10 @@ class VisualEmotionRecognitionAgent(BaseAgent):
Compare emotions from previous window and current emotions,
send updates to BDI Core Agent.
"""
# Remove emotions that are no longer present
emotions_to_remove = prev_emotions - emotions
new_emotions = emotions - prev_emotions
emotions_to_add = emotions - prev_emotions
if not new_emotions and not emotions_to_remove:
if not emotions_to_add and not emotions_to_remove:
return
emotion_beliefs = []
@@ -122,18 +121,20 @@ class VisualEmotionRecognitionAgent(BaseAgent):
self.logger.warning("Invalid belief for emotion removal: %s", emotion)
# Add new emotions that have appeared
for emotion in new_emotions:
for emotion in emotions_to_add:
self.logger.info(f"New emotion detected: '{emotion}'")
try:
emotion_beliefs.append(Belief(name="emotion", arguments=[emotion]))
except ValidationError:
self.logger.warning("Invalid belief for new emotion: %s", emotion)
beliefs_list = [b.model_dump() for b in emotion_beliefs]
payload = {"beliefs": beliefs_list}
message = InternalMessage(
to=settings.agent_settings.bdi_core_name,
sender=self.name,
body=json.dumps(emotion_beliefs),
body=json.dumps(payload),
thread="beliefs",
)
self.logger.debug("Sending emotion beliefs update: %s", emotion_beliefs)
await self.send(message)

View File

@@ -40,9 +40,6 @@ from control_backend.agents.communication import RICommunicationAgent
from control_backend.agents.llm import LLMAgent
# User Interrupt Agent
from control_backend.agents.perception.visual_emotion_detection_agent.visual_emotion_recognition_agent import (
VisualEmotionRecognitionAgent,
)
from control_backend.agents.user_interrupt.user_interrupt_agent import UserInterruptAgent
# Other backend imports