コード例 #1
0
def _make_attribute(name, value):
    if isinstance(value, bool):
        return etad.BooleanAttribute(name, value)

    if etau.is_numeric(value):
        return etad.NumericAttribute(name, value)

    return etad.CategoricalAttribute(name, value)
コード例 #2
0
ファイル: cvat.py プロジェクト: xibeiwind/fiftyone
    def to_eta_attribute(self):
        """Returns an ``eta.core.data.Attribute`` representation of the
        attribute.

        Returns:
            an ``eta.core.data.Attribute``
        """
        if isinstance(self.value, bool):
            return etad.BooleanAttribute(self.name, self.value)

        if etau.is_numeric(self.value):
            return etad.NumericAttribute(self.name, self.value)

        return etad.CategoricalAttribute(self.name, self.value)
コード例 #3
0
def _to_eta_attributes(attributes):
    attrs = etad.AttributeContainer()
    for attr_name, attr in attributes.items():
        attr_value = attr.value
        if isinstance(attr_value, bool):
            _attr = etad.BooleanAttribute(attr_name, attr_value)
        elif etau.is_numeric(attr_value):
            _attr = etad.NumericAttribute(attr_name, attr_value)
        else:
            _attr = etad.CategoricalAttribute(attr_name, str(attr_value))

        attrs.add(_attr)

    return attrs
コード例 #4
0
ファイル: labels.py プロジェクト: Flavio58it/fiftyone
    def to_detected_object(self, name=None):
        """Returns an ``eta.core.objects.DetectedObject`` representation of
        this instance.

        Args:
            name (None): the name of the label field

        Returns:
            an ``eta.core.objects.DetectedObject``
        """
        label = self.label

        # pylint: disable=unpacking-non-sequence
        tlx, tly, w, h = self.bounding_box
        brx = tlx + w
        bry = tly + h
        bounding_box = etag.BoundingBox.from_coords(tlx, tly, brx, bry)

        confidence = self.confidence

        # pylint: disable=no-member
        attrs = etad.AttributeContainer()
        for attr_name, attr in self.attributes.items():
            attr_value = attr.value
            if isinstance(attr_value, bool):
                _attr = etad.BooleanAttribute(attr_name, attr_value)
            elif etau.is_numeric(attr_value):
                _attr = etad.NumericAttribute(attr_name, attr_value)
            else:
                _attr = etad.CategoricalAttribute(attr_name, str(attr_value))

            attrs.add(_attr)

        return etao.DetectedObject(
            label=label,
            bounding_box=bounding_box,
            confidence=confidence,
            name=name,
            attrs=attrs,
        )