def from_cvat_tracks(cls, cvat_tracks): """Creates a :class:`CVATTaskLabels` instance that describes the active schema of the given annotations. Args: cvat_tracks: a list of :class:`CVATTrack` instances Returns: a :class:`CVATTaskLabels` """ schema = etai.ImageLabelsSchema() for cvat_track in cvat_tracks: for box in cvat_track.boxes.values(): _label = box.label schema.add_object_label(_label) if box.outside is not None: schema.add_object_attribute("outside", box.outside) if box.occluded is not None: schema.add_object_attribute("occluded", box.occluded) if box.keyframe is not None: schema.add_object_attribute("keyframe", box.keyframe) for attr in box.attributes: _attr = attr.to_eta_attribute() schema.add_object_attribute(_label, _attr) return cls.from_schema(schema)
def to_schema(self): """Returns an ``eta.core.image.ImageLabelsSchema`` representation of the task labels. Returns: an ``eta.core.image.ImageLabelsSchema`` """ schema = etai.ImageLabelsSchema() for label in self.labels: _label = label["name"] schema.add_object_label(_label) for attribute in label.get("attributes", []): _name = attribute["name"] _categories = attribute["categories"] for _value in _categories: _attr = etad.CategoricalAttribute(_name, _value) schema.add_object_attribute(_label, _attr) return schema
def from_cvat_images(cls, cvat_images): """Creates a :class:`CVATTaskLabels` instance that describes the active schema of the given annotations. Args: cvat_images: a list of :class:`CVATImage` instances Returns: a :class:`CVATTaskLabels` """ schema = etai.ImageLabelsSchema() for cvat_image in cvat_images: for box in cvat_image.boxes: _label = box.label schema.add_object_label(_label) for attr in box.attributes: _attr = attr.to_eta_attribute() schema.add_object_attribute(_label, _attr) return cls.from_schema(schema)