kolena.workflow.Inference
#
The output from a Model
. In other words, a model is a deterministic transformation from a
TestSample
to an Inference
.
from dataclasses import dataclass
from typing import Optional
from kolena.workflow import Inference
from kolena.workflow.annotation import Keypoints
@dataclass(frozen=True)
class PoseEstimate(Inference):
skeleton: Optional[Keypoints] = None # leave empty if nothing is detected
confidence: Optional[float] = None
Inference
#
Bases: DataObject
The inference produced by a model.
Typically the structure of this object closely mirrors the structure of the
GroundTruth
for a workflow, but this is not a requirement.
During evaluation, the TestSample
objects, ground truth objects, and these inference
objects are provided to the Evaluator
implementation to compute metrics.
This object may contain any combination of scalars (e.g. str
, float
),
Annotation
objects, or lists of these objects.
A model processing a Composite
test sample can produce an inference result for each
of its elements. To associate an inference result to each test sample element, put the attributes and/or annotations
inside a DataObject
and use the same attribute name as that used in the Composite
test sample.
Continue with the example given in Composite
, where the FacePairSample
test sample
type is defined using a pair of images under the source
and target
members, we can design a corresponding
inference type with image-level annotations defined in the FaceRegion
object:
from dataclasses import dataclass
from kolena.workflow import DataObject, Inference
from kolena.workflow.annotation import BoundingBox, Keypoints
@dataclass(frozen=True)
class FaceRegion(DataObject):
bounding_box: BoundingBox
keypoints: Keypoints
@dataclass(frozen=True)
class FacePair(Inference):
source: FaceRegion
target: FaceRegion
similarity: float
This way, it is clear which bounding boxes and keypoints are associated to which image in the test sample.