TransformersImageClassification
Basic image classification task
Subclass of Task.
Module: implementation.tasks
Default predictor
This task uses TransformersModel by default with this configuration:
See:
Methods and properties
Main methods and properties
__init__
Arguments:
predictor (Predictor[Any, Any], optional): Predictor that will be used in task. If equals to None, default predictor will be used. Defaults to None.
preprocess (Optional[Component], optional): Component executed before predictor. If equals to None, default component will be used. Defaults to None. Default component: ImagePad | ImageClassificationPreprocessor If default chain is used, ImageClassificationPreprocessor will use AutoImageProcessor from model used in predictor.
postprocess (Optional[Component], optional): Component executed after predictor. If equals to None, default component will be used. Defaults to None. Default component: ImageClassificationSingleLabelPostprocessor If default chain is used, ImageClassificationSingleLabelPostprocessor will use labels from model used in predictor.
input_class (Type[Input], optional): Class for input validation. Defaults to TransformersImageClassificationInput.
output_class (Type[Output], optional): Class for output validation. Defaults to TransformersImageClassificationOutput.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
TransformersImageClassificationInput
Subclass of IOModel.
__init__
Arguments:
image (Image.Image): Image to process.
TransformersImageClassificationOutput
Subclass of IOModel.
__init__
Arguments:
label (Optional[Tuple[str, float]]): Classified label and score.
TransformersImageClassificationMultilabelOutput
Subclass of IOModel.
__init__
Arguments:
labels (Dict[str, float]): Classified labels and scores.
ImageClassificationPreprocessor
Prepare model input. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].
__init__
Arguments:
processor (Processor): Feature extractor.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"image" (Image.Image): Image to analyze;
Returns:
Dict[str, Any]: Expected keys:
"pixel_values" (Any);
ImageClassificationSingleLabelPostprocessor
Process model output. Subclass of ImageClassificationMultilabelPostprocessor.
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"logits" (Any): Model output;
Returns:
Dict[str, Any]: Expected keys:
"label" (Optional[Tuple[str, float]]): Label with highest score, if score higher or equal to threshold, else - None.
ImageClassificationMultilabelPostprocessor
Process model output. Subclass of Action. Type of Action[Dict[str, Any], Dict[str, Any]].
__init__
Arguments:
labels (Mapping[Any, str]): Labels for classification.
threshold (float): Labels threshold score. Defaults to 0.
name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.
execute
Arguments:
input_data (Dict[str, Any]): Expected keys:
"logits" (Any): Model output;
Returns:
Dict[str, Any]: Expected keys:
"labels" (Dict[str, float]): Classified labels and scores.
Last updated