Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/yarrow/yarrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,8 @@ class Category(BaseModel):
super_category : Optional[str]
keypoints : Optional[List[str]]
skeleton : Optional[List[Edge]]
confidence : Optional[float]
threshold : Optional[float]
# fmt: on

def __eq__(self, other) -> bool:
Expand All @@ -162,12 +164,22 @@ def __eq__(self, other) -> bool:
self.name == other.name,
self.value == other.value,
self.super_category == other.super_category,
self.confidence == other.confidence,
self.threshold == other.threshold,
)
)
return NotImplemented

def __hash__(self):
return hash((self.name, self.value, self.super_category))
return hash(
(
self.name,
self.value,
self.super_category,
self.confidence,
self.threshold,
)
)


class RLE(BaseModel):
Expand Down Expand Up @@ -253,6 +265,8 @@ class Annotation_pydantic(BaseModel):
weight : Optional[float]
date_captured : Optional[datetime]
meta : Optional[dict]
confidence : Optional[float]
threshold : Optional[float]
# fmt: on

def __eq__(self, other) -> bool:
Expand Down
6 changes: 6 additions & 0 deletions src/yarrow/yarrow_cls.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ def __init__(
weight: float = None,
date_captured: datetime = None,
meta: dict = None,
confidence: float = None,
threshold: float = None,
**kwargs
) -> None:
"""Annotation class, can handle bbox, polygon, mask and keypoint annotation types \
Expand Down Expand Up @@ -160,6 +162,8 @@ def __init__(
weight (float, optional): weight given to the quality of the annotation. Defaults to None.
date_captured (datetime, optional): datetime at which the annotation was created. Defaults to None.
meta (dict, optional): a free metadata information key. If the Annotation cannot hold your information then put it here
confidence (float, optional): Confidence level of the prediction. Defaults to None.
threshold (float, optional): Threshold to compare the confidence level. Defaults to None.
"""
self.name = name

Expand Down Expand Up @@ -202,6 +206,8 @@ def __init__(
self.weight = weight
self.date_captured = date_captured
self.meta = meta or {}
self.confidence = confidence
self.threshold = threshold

self._pydantic_self = None

Expand Down