Skip to content

Commit 8178653

Browse files
committed
feat: add abstract base class of metric (#157)
Signed-off-by: ktro2828 <kotaro.uetake@tier4.jp>
1 parent 3afb6e0 commit 8178653

3 files changed

Lines changed: 20 additions & 2 deletions

File tree

t4_devkit/evaluation/metric/ap.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
import numpy as np
66
from attrs import define, field
77

8+
from .base import BaseMetric
9+
810
if TYPE_CHECKING:
911
from t4_devkit.evaluation import BoxMatch, FrameBoxMatch, MatchingScorerLike
1012

1113
__all__ = ["Ap", "ApH"]
1214

1315

14-
class Ap:
16+
class Ap(BaseMetric):
1517
num_recall_point = 101
1618
min_precision = 0.1
1719
min_recall = 0.1
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
from __future__ import annotations
2+
3+
from abc import ABC, abstractmethod
4+
from typing import TYPE_CHECKING
5+
6+
if TYPE_CHECKING:
7+
from t4_devkit.evaluation import FrameBoxMatch
8+
9+
10+
class BaseMetric(ABC):
11+
@abstractmethod
12+
def __call__(self, frames: list[FrameBoxMatch]) -> float:
13+
"""Compute metric score."""
14+
...

t4_devkit/evaluation/metric/clear.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44

55
from attrs import define, field
66

7+
from .base import BaseMetric
8+
79
if TYPE_CHECKING:
810
from t4_devkit.evaluation import BoxMatch, FrameBoxMatch, MatchingScorerLike
911

1012
__all__ = ["Mota", "Motp"]
1113

1214

13-
class Mota:
15+
class Mota(BaseMetric):
1416
@define
1517
class ClearBuffer:
1618
num_gt: int = field(init=False, default=0)

0 commit comments

Comments
 (0)