finalproject / services /__init__.py
jarondon82's picture
Initial commit for EmotionMirror finalproject
f7e620e
"""
Services package for EmotionMirror application.
Contains modular services for image processing, model management and emotion analysis.
"""
import logging
from config import settings
from services.emotion_service import EmotionService
# Import DeepFaceEmotionService conditionally to avoid errors if deepface isn't installed
try:
from services.deepface_emotion_service import DeepFaceEmotionService, DEEPFACE_AVAILABLE
except ImportError:
logging.warning("DeepFaceEmotionService could not be imported. Advanced emotion detection will be unavailable.")
DeepFaceEmotionService = None
DEEPFACE_AVAILABLE = False
def get_emotion_service():
"""
Factory function that returns the appropriate emotion service based on configuration.
Returns:
EmotionService: The configured emotion service (basic or advanced)
"""
# Choose between basic and advanced emotion service based on configuration
if settings.USE_ADVANCED_EMOTION and DEEPFACE_AVAILABLE and DeepFaceEmotionService is not None:
try:
# Simplemente intentamos crear el servicio avanzado
logging.info("Using advanced emotion detection with DeepFace")
return DeepFaceEmotionService()
except Exception as e:
logging.error(f"Error initializing DeepFaceEmotionService: {e}")
logging.warning("Falling back to basic emotion service")
# Fall back to basic emotion service
logging.info("Using basic emotion service")
return EmotionService()