core.engines package¶
Submodules¶
core.engines.tensorflow_engine module¶
A Tensorflow_engine module.
This module contains the TensorFlowEngine and related classes, which are used to run inference on a TensorFlow model.
- Classes:
TFModelConfig: A Class encapsulates TensorFlow specified configuration for the model. TensorFlowPreprocessor: A class for preprocessing input data for TensorFlow models. TensorFlowPostprocessor: A class for postprocessing output data for TensorFlow models. TensorFlowEngine: A concrete class implementing the InferenceEngine for TensorFlow framework.
- class core.engines.tensorflow_engine.TFModelConfig(path: str, dtype: str, target: str, device: str = 'CPU')¶
Bases:
object
A Class encapsulates TensorFlow specified configuration for the model.
This class holds configuration data required to run a TensorFlow model.
- Variables
_path (str) – The path to the model.
_dtype (str) – The data type of the model.
_device (str) – The device to run the model on.
_target (str) – The target task of the model.
_output_layer (list) – The output layers of the model.
_drawing (dict) – The drawing configuration of the inference task.
- property device: str¶
The device to run the inference on.
- Type
str
- property drawing: dict¶
The drawing configuration of the inference task.
- Type
dict
- property dtype: str¶
The data type of the model.
- Type
str
- property output_layer: list¶
The output layers of the model.
- Type
list
- property path: str¶
The model file path.
- Type
str
- property target: str¶
The target of the inference task.
- Type
str
- class core.engines.tensorflow_engine.TensorFlowEngine(config: core.engines.tensorflow_engine.TFModelConfig)¶
Bases:
core.infereng.InferenceEngine
A concrete class implementing the InferenceEngine for TensorFlow framework.
This class implement verify, preprocess, postprocess, _predict methods defined in InferenceEngine abstract base class for TensorFlow framework.
- Variables
_model_path (str) – The inference model file path.
_dtype (str) – The data type of the inference model.
_drawing (dict) – The drawing configuration of the inference task.
_output_layer (list) – The output layers of the inference model.
_input_size (Tuple[int, int]) – The expected input size of the inference model.
_model (dict) – The dictionary representing the inference model.
_session (tf.compat.v1.Session) – The Tensorflow Session object of the inference model.
_preprocessor (Preprocessor) – The Preprocessor object for preprocessing the input data.
_postprocessor (Postprocessor) – The Postprocessor object for postprocessing the output data.
- property input_size: Tuple[int, int]¶
The input size of the TensorFlow model.
- Type
Tuple[int, int]
- postprocess(frame: numpy.ndarray, outputs: dict) numpy.ndarray ¶
Implement the postprocess method for TensorFlow models.
The method overrides the postprocess method defined in the InferenceEngine abstract base class.
- preprocess(frame: numpy.ndarray) numpy.ndarray ¶
Implement the preprocess method for TensorFlow models.
The method overrides the preprocess method defined in the InferenceEngine abstract base class.
- verify() bool ¶
Implement the verify method for TensorFlow models.
The method overrides the verify method defined in the InferenceEngine abstract base class.
- class core.engines.tensorflow_engine.TensorFlowPostprocessor(target: str, drawing: dict)¶
Bases:
core.processors.postprocessor.Postprocessor
A class for postprocessing output data for TensorFlow models.
This class postprocesses the output data by drawing the results on the output frame.
- Variables
_postprocessor (Postprocessor) – A Postprocessor object representing the appropriate postprocessor for the output data of TensorFlow models.
- postprocess(frame: numpy.ndarray, outputs: dict) numpy.ndarray ¶
Implement the postprocess method for TensorFlow models.
The method overrides the postprocess method defined in the Postprocessor abstract base class.
- class core.engines.tensorflow_engine.TensorFlowPreprocessor(input_size: Tuple[int, int], dtype: str)¶
Bases:
core.processors.preprocessor.Preprocessor
A class for preprocessing input data for TensorFlow models.
This class preprocesses the input data by resizing and converting to the appropriate data type.
- Variables
_input_size (Tuple[int, int]) – The expected input size of the model.
_dtype (str) – The data type of the model.
- preprocess(frame: numpy.ndarray) numpy.ndarray ¶
Implement the preprocess method for TensorFlow models.
The method overrides the preprocess method defined in the Preprocessor abstract base class.
Module contents¶
The core.engines package.
This package contains the implementations of engines, which are used to run the model inference.