Skip to content

Groundtruth

Bases: StaticCollection

An object describing a ground truth (e.g., a human-drawn bounding box on an image).

Attributes:

Name Type Description
datum Datum

The datum associated with the groundtruth.

annotations List[Annotation]

The list of annotations associated with the groundtruth.

Examples:

>>> GroundTruth(
...     datum=Datum(uid="uid1"),
...     annotations=[
...         Annotation(
...             labels=[Label(key="k1", value="v1")],
...         )
...     ]
... )
Source code in valor/coretypes.py
class GroundTruth(StaticCollection):
    """
    An object describing a ground truth (e.g., a human-drawn bounding box on an image).

    Attributes
    ----------
    datum : Datum
        The datum associated with the groundtruth.
    annotations : List[Annotation]
        The list of annotations associated with the groundtruth.

    Examples
    --------
    >>> GroundTruth(
    ...     datum=Datum(uid="uid1"),
    ...     annotations=[
    ...         Annotation(
    ...             labels=[Label(key="k1", value="v1")],
    ...         )
    ...     ]
    ... )
    """

    datum: Datum = Datum.symbolic(owner="groundtruth", name="datum")
    annotations: SymbolicList[Annotation] = SymbolicList[Annotation].symbolic(
        owner="groundtruth", name="annotations"
    )

    def __init__(
        self,
        *,
        datum: Datum,
        annotations: List[Annotation],
    ):
        """
        Creates a ground truth.

        Parameters
        ----------
        datum : Datum
            The datum that the ground truth is operating over.
        annotations : List[Annotation]
            The list of ground truth annotations.
        """
        super().__init__(datum=datum, annotations=annotations)

        for annotation in self.annotations:
            for label in annotation.labels:
                if label.score is not None:
                    raise ValueError(
                        "GroundTruth labels should not have scores."
                    )

Functions

valor.GroundTruth.__init__(*, datum, annotations)

Creates a ground truth.

Parameters:

Name Type Description Default
datum Datum

The datum that the ground truth is operating over.

required
annotations List[Annotation]

The list of ground truth annotations.

required
Source code in valor/coretypes.py
def __init__(
    self,
    *,
    datum: Datum,
    annotations: List[Annotation],
):
    """
    Creates a ground truth.

    Parameters
    ----------
    datum : Datum
        The datum that the ground truth is operating over.
    annotations : List[Annotation]
        The list of ground truth annotations.
    """
    super().__init__(datum=datum, annotations=annotations)

    for annotation in self.annotations:
        for label in annotation.labels:
            if label.score is not None:
                raise ValueError(
                    "GroundTruth labels should not have scores."
                )