Bases: StaticCollection
An object for labeling datasets, models, and annotations.
Attributes:
Name |
Type |
Description |
key |
String
|
|
value |
String
|
|
score |
Score
|
|
Examples:
>>> Label(key="k1", value="v1")
>>> Label(key="k1", value="v1", score=None)
>>> Label(key="k1", value="v1", score=0.9)
Source code in valor/schemas/symbolic/collections.py
| class Label(StaticCollection):
"""
An object for labeling datasets, models, and annotations.
Attributes
----------
key : String
The class label key.
value : String
The class label value.
score : Score
The label score.
Examples
--------
>>> Label(key="k1", value="v1")
>>> Label(key="k1", value="v1", score=None)
>>> Label(key="k1", value="v1", score=0.9)
"""
key: String = String.symbolic(owner="label", name="key")
value: String = String.symbolic(owner="label", name="value")
score: Float = Float.symbolic(owner="label", name="score")
def __init__(
self,
*,
key: str,
value: str,
score: Union[float, np.floating, None] = None,
):
"""
Initializes an instance of a label.
Attributes
----------
key : str
The class label key.
value : str
The class label value.
score : float, optional
The label score.
"""
super().__init__(key=key, value=value, score=score)
@staticmethod
def formatting() -> Dict[str, Any]:
"""Attribute format mapping."""
return {
"score": Float.nullable,
}
def tuple(self):
"""
Defines how the `Label` is turned into a tuple.
Returns
----------
tuple
A tuple of the `Label's` arguments.
"""
return (self.key, self.value, self.score)
|
Functions
valor.Label.__init__(*, key, value, score=None)
Initializes an instance of a label.
Attributes:
Name |
Type |
Description |
key |
str
|
|
value |
str
|
|
score |
(float, optional)
|
|
Source code in valor/schemas/symbolic/collections.py
| def __init__(
self,
*,
key: str,
value: str,
score: Union[float, np.floating, None] = None,
):
"""
Initializes an instance of a label.
Attributes
----------
key : str
The class label key.
value : str
The class label value.
score : float, optional
The label score.
"""
super().__init__(key=key, value=value, score=score)
|
Attribute format mapping.
Source code in valor/schemas/symbolic/collections.py
| @staticmethod
def formatting() -> Dict[str, Any]:
"""Attribute format mapping."""
return {
"score": Float.nullable,
}
|
valor.Label.tuple()
Defines how the Label
is turned into a tuple.
Returns:
Type |
Description |
tuple
|
A tuple of the Label's arguments.
|
Source code in valor/schemas/symbolic/collections.py
| def tuple(self):
"""
Defines how the `Label` is turned into a tuple.
Returns
----------
tuple
A tuple of the `Label's` arguments.
"""
return (self.key, self.value, self.score)
|