Shortcuts

ClassificationInputMixin

class flash.core.data.io.classification_input.ClassificationInputMixin(running_stage=None)[source]

The ClassificationInputMixin class provides utility methods for handling classification targets. Input objects that extend ClassificationInputMixin should do the following:

  • In the load_data method, include a call to load_target_metadata. This will determine the format of the targets and store metadata like labels and num_classes.

  • In the load_sample method, use format_target to convert the target to a standard format for use with our tasks.

format_target(target)[source]

Format a single target according to the previously computed target format and metadata.

Parameters

target (Any) – The target to format.

Return type

Any

Returns

The formatted target.

load_target_metadata(targets, target_formatter=None, add_background=False)[source]

Determine the target format and store the labels and num_classes.

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

  • target_formatter (Optional[TargetFormatter]) – Optionally provide a TargetFormatter rather than inferring from the targets.

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

Return type

None