Ejemplo n.º 1
0
def df2classifications(df):
    """Converts a pandas DataFrame to a
    :class:`fiftyone.core.labels.Classifications` instance.

    Args:
        df: a pandas.DataFrame
            Required columns:
                LabelName   - the label MID
                Confidence  - float [0, 1]

            Optional Columns:
                Source      - 'freeform', 'verification', ...

    Returns:
         a :class:`fiftyone.core.labels.Classifications` instance
    """
    supplemental_columns = [fn for fn in CLASSIFICATION_COLUMNS if fn in df]

    return fol.Classifications(classifications=[
        fol.Classification(
            label=row.LabelName,
            confidence=row.Confidence,
            **{sc: row[sc]
               for sc in supplemental_columns},
        ) for _, row in df.iterrows()
    ])
Ejemplo n.º 2
0
    def _parse_label(self, target):
        try:
            label = self.classes[target]
        except:
            label = str(target)

        return fol.Classification(label=label)
Ejemplo n.º 3
0
 def _parse_label(self, features):
     label = features["label"].numpy().decode()
     return fol.Classification(label=label)