Yolo#
- class model_api.models.yolo.DetectionBox(x, y, w, h)#
Bases:
tupleCreate new instance of DetectionBox(x, y, w, h)
- h#
Alias for field number 3
- w#
Alias for field number 2
- x#
Alias for field number 0
- y#
Alias for field number 1
- class model_api.models.yolo.YOLO(inference_adapter, configuration, preload=False)#
Bases:
DetectionModelDetection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- class Params(param, sides)#
Bases:
object
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- postprocess(outputs, meta)#
Interface for postprocess method.
- Parameters:
outputs (dict) –
model raw output in the following format: {
’output_layer_name_1’: raw_result_1, ‘output_layer_name_2’: raw_result_2, …
}
meta (dict) – the input metadata obtained from preprocess method
- Return type:
DetectionResult- Returns:
postprocessed data in the format defined by wrapper
- class model_api.models.yolo.YOLOF(inference_adapter, configuration={}, preload=False)#
Bases:
YOLODetection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- class Params(classes, num, sides, anchors)#
Bases:
object
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- class model_api.models.yolo.YOLOX(inference_adapter, configuration={}, preload=False)#
Bases:
DetectionModelDetection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- postprocess(outputs, meta)#
Interface for postprocess method.
- Parameters:
outputs (dict) –
model raw output in the following format: {
’output_layer_name_1’: raw_result_1, ‘output_layer_name_2’: raw_result_2, …
}
meta (dict) – the input metadata obtained from preprocess method
- Return type:
DetectionResult- Returns:
postprocessed data in the format defined by wrapper
- set_strides_grids()#
- class model_api.models.yolo.YOLOv5(inference_adapter, configuration, preload=False)#
Bases:
DetectionModelReimplementation of ultralytics.YOLO
Detection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- postprocess(outputs, meta)#
Interface for postprocess method.
- Parameters:
outputs (dict) –
model raw output in the following format: {
’output_layer_name_1’: raw_result_1, ‘output_layer_name_2’: raw_result_2, …
}
meta (dict) – the input metadata obtained from preprocess method
- Return type:
DetectionResult- Returns:
postprocessed data in the format defined by wrapper
- class model_api.models.yolo.YOLOv8(inference_adapter, configuration, preload=False)#
Bases:
YOLOv5YOLOv5 and YOLOv8 are identical in terms of inference
Detection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- class model_api.models.yolo.YoloV3ONNX(inference_adapter, configuration={}, preload=False)#
Bases:
DetectionModelDetection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- postprocess(outputs, meta)#
Interface for postprocess method.
- Parameters:
outputs (dict) –
model raw output in the following format: {
’output_layer_name_1’: raw_result_1, ‘output_layer_name_2’: raw_result_2, …
}
meta (dict) – the input metadata obtained from preprocess method
- Return type:
DetectionResult- Returns:
postprocessed data in the format defined by wrapper
- preprocess(dict_inputs, meta)#
Interface for preprocess hook.
- Parameters:
dict_inputs (
dict) – preprocessed datameta (
dict) – input metadata
- Return type:
tuple[dict,dict]- Returns:
the preprocessed data
the input metadata
- class model_api.models.yolo.YoloV4(inference_adapter, configuration={}, preload=False)#
Bases:
YOLODetection Model constructor
It extends the ImageModel construtor.
- Parameters:
inference_adapter (InferenceAdapter) – allows working with the specified executor
configuration (dict, optional) – it contains values for parameters accepted by specific wrapper (confidence_threshold, labels 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 model has more than 1 image inputs
- class Params(classes, num, sides, anchors, mask, layout)#
Bases:
object
- 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.
- Returns:
the dictionary with defined wrapper data parameters
- model_api.models.yolo.permute_to_N_HWA_K(tensor, K, output_layout)#
Transpose/reshape a tensor from (N, (A x K), H, W) to (N, (HxWxA), K)
- model_api.models.yolo.sigmoid(x)#
- model_api.models.yolo.xywh2xyxy(xywh)#