-
Notifications
You must be signed in to change notification settings - Fork 19
/
core.py
48 lines (38 loc) · 1.37 KB
/
core.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
"""Defines interface for CVU-Cores.
A core defines one complete method/solution for certain use cases.
For example, YoloV5 is a core of Object Detection use cases.
"""
import abc
from typing import Union, List
import numpy as np
from .predictions import IPredictions
class ICore(metaclass=abc.ABCMeta):
"""Core Interface which will be implemented for every CVU-Core.
A core defines one complete method/solution for certain use cases.
For example, YoloV5 is a core of Object Detection use cases.
"""
@abc.abstractmethod
def __init__(self, classes: Union[str, List[str]], backend: str, *args,
**kwargs) -> None:
"""Initiate Core.
Args:
classes (Union[str, List[str]]): single object class name or list of classes
backend (str): name of the backend to run core on.
"""
...
@abc.abstractmethod
def __call__(self, inputs: np.ndarray, **kwargs) -> IPredictions:
"""Execute core on inputs
Args:
inputs (np.ndarray): inputs to be exectued core on
Returns:
Predictions: results of executation
"""
...
@abc.abstractmethod
def __repr__(self) -> str:
"""Represents core with method and configuration informations.
Returns:
str: formatted string with method and config info.
"""
...