TransformersObjectDetection

Basic object detection task

Subclass of Task.

Module: implementation.tasks

Default predictor

This task uses TransformersModel by default with this configuration:

model = DetrForObjectDetection.from_pretrained(
    "facebook/detr-resnet-50", revision="no_timm"
)
predictor=TransformersModel(
    TransformersModelConfig(
        model=model
    ),
    input_class=TransformersImageClassificationModelInput,
    output_class=TransformersDETROutput,
)

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: ObjectDetectionPreprocessor If default chain is used, ObjectDetectionPreprocessor will use DetrImageProcessor 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: DETRPostprocessor If default chain is used, DETRPostprocessor will use DetrImageProcessor and labels from model used in predictor.

  • input_class (Type[Input], optional): Class for input validation. Defaults to TransformersObjectDetectionInput.

  • output_class (Type[Output], optional): Class for output validation. Defaults to TransformersObjectDetectionOutput.

  • name (Optional[str], optional): Name for identification. If equals to None, class name will be used. Defaults to None.




TransformersObjectDetectionInput

Subclass of IOModel.


__init__

Arguments:

  • image (Image.Image): Image to process.




TransformersObjectDetectionOutput

Subclass of IOModel.


__init__

Arguments:

  • scores (List[float]): Probability scores.

  • labels (List[str]): Classified labels.

  • boxes (List[Tuple[float, float, float, float]]): Bounding boxes.




ObjectDetectionPreprocessor

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);




DETRPostprocessor

Process model output. Subclass of VisualQandAMultianswerPostprocessor.


__init__

Arguments:

  • processor (DetrImageProcessor): Feature extractor.

  • 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:

    • "image" (Image.Image): Processed image;

    • "logits" (Any): Model output;

    • "pred_boxes" (Any);

Returns:

  • Dict[str, Any]: Expected keys:

    • "scores" (List[float]): Probability scores.

    • "labels" (List[str]): Classified labels.

    • "boxes" (List[Tuple[float, float, float, float]]): Bounding boxes.



Last updated