File size: 1,078 Bytes
3bec0b6
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
from abc import ABC, abstractmethod
import numpy as np 

class BaseDetector(ABC): 
    """
    The Interface (Blueprint).
    All models (YOLO, MobileNet, ResNet, RCE) must inherit from this class.
    
    This ensures that the benchmark script can treat them all exactly the same.
    """
    @abstractmethod
    def load_model(self): 
        """
        Initialize the model architecture and load weights from disk.
        This must happen before prediction.
        """
        pass 
    
    @abstractmethod
    def predict(self, image :np.ndarray): 
        """
        Run inference on a single image.
        
        Args:
            image (np.ndarray): A BGR image from OpenCV (Height, Width, Channels).
            
        Returns:
            tuple: A tuple containing exactly 3 elements:
                1. label (str): The name of the detected object (e.g., 'bird', 'mug').
                2. confidence (float): How sure the model is (0.0 to 1.0).
                3. inference_time (float): Processing time in milliseconds.
        """
        pass