class documentation

Generic parser for image classification(s) samples whose labels are represented as fiftyone.core.labels.Classification instances.

This implementation supports samples that are (image_or_path, target) tuples, where:

  • image_or_path is either an image that can be converted to numpy format via np.asarray() or the path to an image on disk

  • target can be any of the following:

    • None, for unlabeled images

    • a label string or list of label strings

    • a class ID or list of class IDs, if classes is provided

    • a dict or list of dicts of the following form:

      {
          "label": <label-or-target>,
          "confidence": <confidence>,
          "attributes": <optional-attributes>,
      }
      
    • a fiftyone.core.labels.Classification or fiftyone.core.labels.Classifications instance

Parameters
classesan optional list of class label strings. If provided, it is assumed that target contains class ID that should be mapped to label strings via classes[target]
Method __init__ Undocumented
Method get_label Returns the label for the current sample.
Instance Variable classes Undocumented
Property label_cls The fiftyone.core.labels.Label class(es) returned by this parser.
Method _parse_label Undocumented

Inherited from LabeledImageTupleSampleParser:

Method clear_sample Clears the current sample.
Method get_image Returns the image from the current sample.
Method get_image_path Returns the image path for the current sample.
Property has_image_metadata Whether this parser produces fiftyone.core.metadata.ImageMetadata instances for samples that it parses.
Property has_image_path Whether this parser produces paths to images on disk for samples that it parses.
Method _get_image Undocumented
Method _parse_image Undocumented
Instance Variable _current_image_cache Undocumented
Property _current_image Undocumented

Inherited from LabeledImageSampleParser (via LabeledImageTupleSampleParser):

Method get_image_metadata Returns the image metadata for the current sample.

Inherited from SampleParser (via LabeledImageTupleSampleParser, LabeledImageSampleParser):

Method with_sample Sets the current sample so that subsequent calls to methods of this parser will return information from the given sample.
Property current_sample The current sample.
Instance Variable _current_sample Undocumented
def get_label(self): (source)

Returns the label for the current sample.

Parameters
samplethe sample
Returns
a fiftyone.core.labels.Classification instance

The fiftyone.core.labels.Label class(es) returned by this parser.

This can be any of the following:

  • a fiftyone.core.labels.Label class. In this case, the parser is guaranteed to return labels of this type
  • a list or tuple of fiftyone.core.labels.Label classes. In this case, the parser can produce a single label field of any of these types
  • a dict mapping keys to fiftyone.core.labels.Label classes. In this case, the parser will return label dictionaries with keys and value-types specified by this dictionary. Not all keys need be present in the imported labels
  • None. In this case, the parser makes no guarantees about the labels that it may return
def _parse_label(self, target): (source)

Undocumented