Shortcuts

get_target_formatter

class flash.core.data.utilities.classification.get_target_formatter(targets, labels=None, num_classes=None, add_background=False)[source]

Get the TargetFormatter object to use for the given targets.

Parameters
  • targets (List[Any]) – The list of targets to format.

  • labels (Optional[List[str]]) – Optionally provide labels / num_classes instead of inferring them.

  • num_classes (Optional[int]) – Optionally provide labels / num_classes instead of inferring them.

  • add_background (bool) – If True, a background class will be inserted as class zero if labels and num_classes are being inferred.

Return type

TargetFormatter

Returns

The target formatter to use when formatting targets.