"""
==================================================
Smart Attendance AI
Inference Service
==================================================
Runs the InsightFace model and returns the
raw InsightFace face objects.

This is the ONLY service that communicates
directly with InsightFace.
==================================================
"""

from typing import List

from config.logger import logger

from core.image_data import ImageData

from models.model_manager import ModelManager


class InferenceService:

    @staticmethod
    def infer(
        image_data: ImageData
    ) -> List:
        """
        Run the AI model and return raw
        InsightFace face objects.
        """

        logger.info(
            "Running AI inference..."
        )

        model = ModelManager.get_model()

        faces = model.get(
            image_data.image
        )

        logger.info(
            "Inference completed. %d face(s) detected.",
            len(faces)
        )

        return faces