Action Classification#
- class model_api.models.action_classification.ActionClassificationModel(inference_adapter, configuration={}, preload=False)#
Bases:
Model
A wrapper for an action classification model
The model given by inference_adapter can have two input formats. One is ‘NSCTHW’ and another one is ‘NSTHWC’. What each letter means are as below. N => batch size / S => number of clips x number of crops / C => number of channels T => time / H => height / W => width The ActionClassificationModel should gets single input with video - 4D tensors, which means N and S should be 1.
Video format is different from image format, so OpenVINO PrePostProcessors isn’t available. For that reason, postprocessing operations such as resize and normalize are conducted in this class.
- image_blob_names#
names of all image-like inputs (6D tensors)
- Type:
List[str]
- image_blob_name#
name of the first image input
- Type:
str
- resize_type#
the type for image resizing (see RESIZE_TYPE for info)
- Type:
str
- resize#
resizing function corresponding to the resize_type
- Type:
function
- input_transform#
instance of the InputTransform for image normalization
- Type:
Action classaification model constructor
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (labels mean_values, etc.) which are set as data attributes
preload (bool, optional) – a flag whether the model is loaded to device while initialization. If preload=False, the model must be loaded via load method before inference
- Raises:
WrapperError – if the wrapper failed to define appropriate inputs for images
- classmethod parameters()#
Defines the description and type of configurable data parameters for the wrapper.
See types.py to find available types of the data parameter. For each parameter the type, default value and description must be provided.
- The example of possible data parameter:
- ‘confidence_threshold’: NumericalValue(
default_value=0.5, description=”Threshold value for detection box confidence”
)
The method must be implemented in each specific inherited wrapper.
- Return type:
dict
[str
,Any
]- Returns:
the dictionary with defined wrapper data parameters
- postprocess(outputs, meta)#
Post-process.
- Return type:
ClassificationResult
- preprocess(inputs)#
Data preprocess method
- It performs basic preprocessing of a single video:
Resizes the image to fit the model input size via the defined resize type
Normalizes the image: subtracts means, divides by scales, switch channels BGR-RGB
Changes the image layout according to the model input layout
Also, it keeps the size of original image and resized one as original_shape and resized_shape in the metadata dictionary.
Note
It supports only models with single image input. If the model has more image inputs or has additional supported inputs, the preprocess should be overloaded in a specific wrapper.
- Parameters:
inputs (ndarray) – a single image as 4D array.
- Returns:
- {
‘input_layer_name’: preprocessed_image
}
the input metadata, which might be used in postprocess method
- Return type:
the preprocessed image in the following format
- property clip_size: int#