EDeepLearningTool represents the common operations of deep learning tools. More...
#include <eVision/EasyDeepLearning/EDeepLearningTool.h>
Public Member Functions | |
| virtual | ~EDeepLearningTool () throw () |
| virtual void | Load (const std::string &filePath) |
| Loads a deep learning tool. The given ESerializer must have been created for reading. | |
| virtual void | Load (eVision::ESerializer *serializer) |
| Loads a deep learning tool. The given ESerializer must have been created for reading. | |
| std::unique_ptr< eVision::EasyDeepLearning::EDeepLearningTool > | Clone () const |
| Clones this tool. | |
| virtual void | Save (const std::string &filePath, bool includeTrainingModel) |
| Saves the settings, inference and training model of the deep learning tool. | |
| virtual void | Save (const std::string &filePath) |
| Saves the settings, inference and training model of the deep learning tool. | |
| virtual void | Save (eVision::ESerializer *serializer, bool includeTrainingModel) |
| Saves the settings, inference and training model of the deep learning tool. | |
| virtual void | Save (eVision::ESerializer *serializer) |
| Saves the settings, inference and training model of the deep learning tool. | |
| virtual void | SerializeSettings (eVision::ESerializer *serializer)=0 |
| Serializes the tool settings. | |
| void | SerializeInferenceModel (eVision::ESerializer *serializer) |
| Serializes the inference model of the tool. | |
| void | SerializeTrainingModel (eVision::ESerializer *serializer) |
| Serializes the training model of the tool. | |
| void | SaveSettings (const std::string &filePath) |
| Saves the settings of the tool to a file. | |
| void | SaveInferenceModel (const std::string &filePath) |
| Saves the tool's inference model to a file. | |
| void | SaveTrainingModel (const std::string &filePath) |
| Saves the tool's training model to a file. | |
| void | LoadSettings (const std::string &filePath) |
| Loads the settings of a tool. | |
| void | LoadInferenceModel (const std::string &filePath) |
| Loads the tool's inference model. The inference model is required to apply the tool on new images. | |
| void | LoadTrainingModel (const std::string &filePath) |
| Loads the tool's training model. The training model is required to continue a training. | |
| void | UnloadInferenceModel () |
| Unloads the inference model. | |
| void | UnloadTrainingModel () |
| Unloads the training model. | |
| void | UnloadModels () |
| Unloads the inference and training model. | |
| bool | HasInferenceModel () const |
| Whether the inference model is loaded or created when the tool is not yet trained. | |
| bool | HasTrainingModel () const |
| Whether the training model is loaded or created when the tool is not yet trained. | |
| virtual eVision::EasyDeepLearning::EDeepLearningToolType | GetToolType () const =0 |
| Type of the deep learning tool. | |
| bool | IsTrained () const |
| Tells whether the deep learning tool has been trained. | |
| void | SetEnableGPU (bool enable) |
| Enable the use of a GPU for training and inference of the deep learning tool. If the active engine is not the default engine, EDeepLearningTool::SetEnableGPU will be false even if the active device has a GPU device type. Setting EDeepLearningTool::SetEnableGPU to any value when the active engine is not the default one will throw an exception. | |
| bool | GetEnableGPU () const |
| Enable the use of a GPU for training and inference of the deep learning tool. If the active engine is not the default engine, EDeepLearningTool::SetEnableGPU will be false even if the active device has a GPU device type. Setting EDeepLearningTool::SetEnableGPU to any value when the active engine is not the default one will throw an exception. | |
| void | SetGPUIndexes (const std::vector< uint32_t > &indexes) |
| Indexes of the GPUs to use for computations. | |
| std::vector< uint32_t > | GetGPUIndexes () const |
| Indexes of the GPUs to use for computations. | |
| uint32_t | GetNumGPUs () const |
| Number of detected NVIDIA GPU. | |
| void | SetEngine (const std::string &engineName) |
| Sets the engine with which to execute or train the neural network. | |
| std::string | GetEngine () const |
| Sets the engine with which to execute or train the neural network. | |
| eVision::EasyDeepLearning::EDeepLearningInferencePrecision | GetInferencePrecision () const |
| Inference precision. | |
| void | SetInferencePrecision (eVision::EasyDeepLearning::EDeepLearningInferencePrecision prec) |
| Inference precision. | |
| int | GetNumAvailableDevices () const |
| Available devices for the current EDeepLearningTool::SetEngine. | |
| std::string | GetAvailableDeviceName (int i) const |
| Name of the i-th device of the current engine. | |
| eVision::EasyDeepLearning::EDeepLearningDevice | GetAvailableDevice (int i) const |
| i-th EDeepLearningDevice of the current engine. | |
| std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > | GetAvailableDevices () const |
| Get all available device for the current engine. | |
| int | GetNumActiveDevices () const |
| Gets the number of devices with which to run or train the model. | |
| void | SetActiveDevice (const eVision::EasyDeepLearning::EDeepLearningDevice &device) |
| Sets the device with which to run or train the model. | |
| eVision::EasyDeepLearning::EDeepLearningDevice | GetActiveDevice (int i) const |
| Gets the active device. By default, it returns the first active device. | |
| eVision::EasyDeepLearning::EDeepLearningDevice | GetActiveDevice () const |
| Gets the active device. By default, it returns the first active device. | |
| void | SetActiveDeviceByName (const std::string &name) |
| Sets the device with which to run the model using its name. | |
| void | SetActiveDeviceById (int id) |
| Sets the device with which to run the model using its index in the list returned by EDeepLearningTool::GetAvailableDevices. | |
| std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > | GetActiveDevices () const |
| Devices with which to run or train the model. | |
| void | SetActiveDevices (const std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > &devices) |
| Devices with which to run or train the model. | |
| void | SetActiveDevicesById (const std::vector< int > &ids) |
| Sets the devices with which to run the model using their index in the list returned by EDeepLearningTool::GetAvailableDevices. | |
| eVision::EasyDeepLearning::EDeepLearningExecutionSettings | GetExecutionSettings () const |
| Execution settings of the tool (engine, device(s), inference precision, batch size settings). | |
| void | SetExecutionSettings (const eVision::EasyDeepLearning::EDeepLearningExecutionSettings &settings) |
| Execution settings of the tool (engine, device(s), inference precision, batch size settings). | |
| bool | HasEngineSetupData () const |
| Whether the inference model has engine setup data. | |
| void | ClearEngineSetupData () |
| Clears the engine data saved in the inference model. Use this method when your engine fails. | |
| eVision::EasyDeepLearning::EDeepLearningDevice | GetEngineSetupDataDevice () const |
| Device corresponding to the engine data contained in the tool. | |
| eVision::EasyDeepLearning::EDeepLearningInferencePrecision | GetEngineSetupDataInferencePrecision () const |
| Inference precision corresponding to the engine data contained in the tool. | |
| int32_t | GetEngineSetupDataBatchSize () const |
| Batch size corresponding to the engine data contained in the tool. | |
| bool | GetOptimizeBatchSize () const |
| Indicates whether to optimize the batch size (see EDeepLearningTool::SetBatchSize) to maximize the training and inference speed according to the engine, the device and the available memory. | |
| void | SetOptimizeBatchSize (bool optimize) |
| Indicates whether to optimize the batch size (see EDeepLearningTool::SetBatchSize) to maximize the training and inference speed according to the engine, the device and the available memory. | |
| int32_t | GetBatchSizeForMaximumInferenceSpeed () const |
| Computes the batch size that will maximize the inference speed on NVIDIA GPU. For all other devices, it will return 1. | |
| void | SetBatchSize (int32_t size) |
| Batch size. The batch size is the number of images that are processed together during training and batch inference. | |
| int32_t | GetBatchSize () const |
| Batch size. The batch size is the number of images that are processed together during training and batch inference. | |
| bool | IsTraining () const |
| Indicates whether the object is currently training. | |
| int | WaitForTrainingCompletion (int timeout) |
| Waits until the training is complete or the timeout is expired. A call to this method will block the calling thread for the shortest time between the timeout and the time it takes for the training to complete. | |
| int | WaitForTrainingCompletion () |
| Waits until the training is complete or the timeout is expired. A call to this method will block the calling thread for the shortest time between the timeout and the time it takes for the training to complete. | |
| int | WaitForIterationCompletion () |
| Waits until an iteration is complete. A call to this method will block the calling thread until a training iteration in the training thread is finished. This method returns the number of trained iterations. | |
| int | StopTraining (bool wait) |
| Stops training and returns the last completed iteration. If the parameter 'wait' is set to true, the method will wait for the training thread to completely stop. Otherwise, the method will return immediately. | |
| float | GetCurrentTrainingProgression () const |
| Current training progression as a percentage (between 0 and 1). | |
| uint32_t | GetCurrentTrainingFinishedIterations () const |
| Number of iterations that are already finished in the current training. | |
| uint32_t | GetCurrentTrainingNumIterations () const |
| Total number of training iterations that will be performed during the current training of the deep learning tool. | |
| uint32_t | GetNumTrainedIterations () const |
| Number of iterations that were performed to train this deep learning tool. | |
| int | GetBestIteration () const |
| Iteration at which the minimum validation error was reached. After training, the tool is in the state it was at this best iteration. | |
| void | SetImageCacheSize (uint64_t size) |
| Size in byte of the image cache. The cache is used during training to store reformatted and normalized images. A correctly sized cache can reduce the hard drive accesses and the preprocessing time for each image. | |
| uint64_t | GetImageCacheSize () const |
| Size in byte of the image cache. The cache is used during training to store reformatted and normalized images. A correctly sized cache can reduce the hard drive accesses and the preprocessing time for each image. | |
| std::string | GetPath () const |
| Path of the tool when loaded or saved using EDeepLearningTool::Save or EDeepLearningTool::Load. | |
| std::string | GetInferenceModelPath () const |
| Path of the inference model when loaded or saved using EDeepLearningTool::SaveInferenceModel, EDeepLearningTool::LoadInferenceModel or EDeepLearningTool::SerializeInferenceModel. | |
| std::string | GetTrainingModelPath () const |
| Path of the training model when loaded or saved using EDeepLearningTool::SaveTrainingModel, EDeepLearningTool::LoadTrainingModel or EDeepLearningTool::SerializeTrainingModel. | |
| std::string | GetSettingsPath () const |
| Path of the settings when loaded or saved using EDeepLearningTool::SaveSettings, EDeepLearningTool::LoadSettings or EDeepLearningTool::SerializeSettings. | |
| void | SetAutoSavePeriod (int period) |
| Auto-save period. The auto-save period is the number of training iterations between each automatic save of the model. | |
| int | GetAutoSavePeriod () const |
| Auto-save period. The auto-save period is the number of training iterations between each automatic save of the model. | |
| void | SetLearningRate (eVision::EasyDeepLearning::EDeepLearningLearningRateType type, const std::vector< float > ¶meters) |
| Specifies how the value of the learning rate and how it evolves during training. | |
| eVision::EasyDeepLearning::EDeepLearningLearningRateType | GetLearningRateType () const |
| Learning rate type. | |
| std::vector< float > | GetLearningRateParameters () const |
| Parameters of the learning rate. | |
| void | SetEnableDeterministicTraining (bool enable) |
| Whether to use deterministic training algorithm that allows to repeatable training results. Default value: false. | |
| bool | GetEnableDeterministicTraining () const |
| Whether to use deterministic training algorithm that allows to repeatable training results. Default value: false. | |
| void | SetDeterministicTrainingRandomSeed (int32_t seed) |
| Random seed to use when EDeepLearningTool::SetEnableDeterministicTraining is set to true. The default value is 42. | |
| int32_t | GetDeterministicTrainingRandomSeed () const |
| Random seed to use when EDeepLearningTool::SetEnableDeterministicTraining is set to true. The default value is 42. | |
| void | InitializeInference (int width, int height, eVision::EImageType imageType, int numImages) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| void | InitializeInference (const eVision::EBaseROI &img) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| void | InitializeInference (std::vector< const eVision::EBaseROI * > &imgList) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| void | InitializeInference (std::vector< eVision::EImageBW8 > &imgList) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| void | InitializeInference (std::vector< eVision::EImageBW16 > &imgList) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| void | InitializeInference (std::vector< eVision::EImageC24 > &imgList) |
| Initializes the neural network for inference (i.e. making predictions with the neural network). | |
| uint32_t | GetNumLabels () const |
| Number of labels of this tool. If the tool is not trained, the method will throw an exception. | |
| std::string | GetLabel (uint32_t index) const |
| Gets the label from its index. If the tool is not trained, the method may throw an exception. | |
| virtual void | SetLabel (uint32_t index, const std::string &label) |
| Changes a label predicted by the tool. | |
| void | SetLabelWeight (uint32_t index, float weight) |
| Sets the label weight. If the tool is not trained, the label weights are not defined. After training, they are set to the value of the training dataset label weights. | |
| float | GetLabelWeight (uint32_t index) const |
| Gets the label weight. If the tool is not trained, the label weights are not defined. After training, they are set to the value of the training dataset label weights. | |
| void | SetLabelColor (uint32_t index, const eVision::ERGBColor &c) |
| Changes a label color. | |
| eVision::ERGBColor | GetLabelColor (uint32_t index) const |
| Label color. The label colors affect how the results will be displayed. | |
| void | SetLabelOpacity (uint32_t index, uint8_t opacity) |
| Changes a label opacity (between 0 for fully transparent and 255 for opaque color). | |
| uint8_t | GetLabelOpacity (uint32_t index) const |
| Gets the label opacity (between 0 for fully transparent and 255 for opaque color). The label opacities affect with the label colors how the results will be displayed. | |
| int | GetOptimalNumImagesForBatchSize (const eVision::EBaseROI &sampleImage) const |
| Optimal number of images to process together for inference given the batch size and EDeepLearningTool::GetNumPatchesForImage. | |
| int | GetOptimalNumImagesForBatchSize (int imageWidth, int imageHeight) const |
| Optimal number of images to process together for inference given the batch size and EDeepLearningTool::GetNumPatchesForImage. | |
| int | GetNumPatchesForImage (const eVision::EBaseROI &sampleImage) const |
| Number of patches that will be extracted from an input image to perform inference. | |
| virtual int | GetNumPatchesForImage (int imageWidth, int imageHeight) const |
| Number of patches that will be extracted from an input image to perform inference. | |
| virtual void | Clean () |
| Reset the engine and clean CPU and GPU memory allocated for running the model. | |
| EDeepLearningTool (CppWrapperInternal::InternalConstructor) | |
Static Public Member Functions | |
| static std::unique_ptr< eVision::EasyDeepLearning::EDeepLearningTool > | Create (const std::string &path) |
| Factory method to open a deep learning tool. | |
| static std::unique_ptr< eVision::EasyDeepLearning::EDeepLearningTool > | Create (eVision::ESerializer *serializer) |
| Factory method to open a deep learning tool. | |
| static std::unique_ptr< eVision::EasyDeepLearning::EDeepLearningTool > | Create (eVision::EasyDeepLearning::EDeepLearningToolType type) |
| Factory method to open a deep learning tool. | |
| static int | GetNumAvailableEngines () |
| Number of available engines. | |
| static std::string | GetAvailableEngineName (int id) |
| Gets the name of the engine given its id. | |
| static std::vector< std::string > | GetAvailableEngines () |
| Available engines. | |
| static std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > | GetAvailableDevicesForEngine (const std::string &engine) |
| Available devices for the specified engine. | |
Public Attributes | |
| CppWrapperInternal::WrappedClass | wrappedClass_ |
EDeepLearningTool represents the common operations of deep learning tools.
The class is responsible for handling CPU/GPU settings and training. Computing the result for an image is called inference and is the responsibility of the actual deep learning tools (see EClassifier).
License(s): EasyClassify or EasySegment or EasyLocate or EasyClassifyInference or EasySegmentInference or EasyLocateInference
|
virtual | ||||||||||||
| eVision::EasyDeepLearning::EDeepLearningTool::EDeepLearningTool | ( | CppWrapperInternal::InternalConstructor | ) |
|
virtual |
Reset the engine and clean CPU and GPU memory allocated for running the model.
This method does not clean all GPU memory. For example, some program data (CUDA kernels) will be kept in GPU memory.
| void eVision::EasyDeepLearning::EDeepLearningTool::ClearEngineSetupData | ( | ) |
Clears the engine data saved in the inference model. Use this method when your engine fails.
| std::unique_ptr< eVision::EasyDeepLearning::EDeepLearningTool > eVision::EasyDeepLearning::EDeepLearningTool::Clone | ( | ) | const |
Clones this tool.
|
static |
Factory method to open a deep learning tool.
| path | Path to a deep learning tool. |
|
static |
Factory method to open a deep learning tool.
| type | Type of tool to create |
|
static |
Factory method to open a deep learning tool.
| serializer | A serializer created for reading. |
| eVision::EasyDeepLearning::EDeepLearningDevice eVision::EasyDeepLearning::EDeepLearningTool::GetActiveDevice | ( | ) | const |
Gets the active device. By default, it returns the first active device.
| eVision::EasyDeepLearning::EDeepLearningDevice eVision::EasyDeepLearning::EDeepLearningTool::GetActiveDevice | ( | int | i | ) | const |
Gets the active device. By default, it returns the first active device.
| i | Index of the active devices between 0 and EDeepLearningTool::GetNumActiveDevices. |
| std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > eVision::EasyDeepLearning::EDeepLearningTool::GetActiveDevices | ( | ) | const |
Devices with which to run or train the model.
Only multiple GPUs with the default engine is supported.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetAutoSavePeriod | ( | ) | const |
Auto-save period. The auto-save period is the number of training iterations between each automatic save of the model.
In order for the model to be automatically saved during the training, the tool must have been loaded or saved to a file. The path where the tool will be saved is either indicated by EDeepLearningTool::GetPath or the three paths EDeepLearningTool::GetSettingsPath, EDeepLearningTool::GetInferenceModelPath, and EDeepLearningTool::GetTrainingModelPath. If one of these path is empty, the corresponding part of the tool will not be saved automatically during training.
By default, auto save is disabled and the period is equal to 0.
| eVision::EasyDeepLearning::EDeepLearningDevice eVision::EasyDeepLearning::EDeepLearningTool::GetAvailableDevice | ( | int | i | ) | const |
i-th EDeepLearningDevice of the current engine.
| i | Index of the device between 0 and EDeepLearningTool::GetNumAvailableDevices - 1. |
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetAvailableDeviceName | ( | int | i | ) | const |
Name of the i-th device of the current engine.
| i | Index of the device between 0 and EDeepLearningTool::GetNumAvailableDevices - 1. |
| std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > eVision::EasyDeepLearning::EDeepLearningTool::GetAvailableDevices | ( | ) | const |
Get all available device for the current engine.
|
static |
Available devices for the specified engine.
| engine | Engine for which to get the devices |
|
static |
Gets the name of the engine given its id.
| id | Index of the available engine between 0 and EDeepLearningTool::GetNumAvailableEngines - 1. |
|
static |
Available engines.
| int32_t eVision::EasyDeepLearning::EDeepLearningTool::GetBatchSize | ( | ) | const |
Batch size. The batch size is the number of images that are processed together during training and batch inference.
When using multi-GPUs processing (see EDeepLearningTool::SetGPUIndexes), the batch size is the number of images that each GPU will process at once.
A large batch size will increase the processing speed on GPU but also the memory requirements.
The batch size must be bigger or equal to 1 and it is commonly chosen to be a power of 2.
If EDeepLearningTool::GetOptimizeBatchSize is 'true', then the value of this property will be optimized automatically for training or inference according to the situation.
See also EDeepLearningTool::GetBatchSizeForMaximumInferenceSpeed.
| int32_t eVision::EasyDeepLearning::EDeepLearningTool::GetBatchSizeForMaximumInferenceSpeed | ( | ) | const |
Computes the batch size that will maximize the inference speed on NVIDIA GPU. For all other devices, it will return 1.
This value is given as an indication and should not necessarily be used in practice.
You must choose a tradeoff between the overall inference speed (also called the throughput), which is limited by this value, and the time it takes to compute the result of a whole batch (also called the latency), which is minimized by making inference image per image (i.e. a batch size of 1). The tradeoff depends on your particular application.
Throw EError_DeepLearningToolNotTrained if the tool is not trained.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetBestIteration | ( | ) | const |
Iteration at which the minimum validation error was reached. After training, the tool is in the state it was at this best iteration.
| uint32_t eVision::EasyDeepLearning::EDeepLearningTool::GetCurrentTrainingFinishedIterations | ( | ) | const |
Number of iterations that are already finished in the current training.
| uint32_t eVision::EasyDeepLearning::EDeepLearningTool::GetCurrentTrainingNumIterations | ( | ) | const |
Total number of training iterations that will be performed during the current training of the deep learning tool.
After the end of the training, this number is the actual number of iterations performed during the training which can be lower than the number of iterations given to the training method (for example if the user called EDeepLearningTool::StopTraining).
| float eVision::EasyDeepLearning::EDeepLearningTool::GetCurrentTrainingProgression | ( | ) | const |
Current training progression as a percentage (between 0 and 1).
| int32_t eVision::EasyDeepLearning::EDeepLearningTool::GetDeterministicTrainingRandomSeed | ( | ) | const |
Random seed to use when EDeepLearningTool::SetEnableDeterministicTraining is set to true. The default value is 42.
When EDeepLearningTool::SetEnableDeterministicTraining, the random seed is generated using a random non-deterministic source.
| bool eVision::EasyDeepLearning::EDeepLearningTool::GetEnableDeterministicTraining | ( | ) | const |
Whether to use deterministic training algorithm that allows to repeatable training results. Default value: false.
Deterministic training is not guaranteed when:
| bool eVision::EasyDeepLearning::EDeepLearningTool::GetEnableGPU | ( | ) | const |
Enable the use of a GPU for training and inference of the deep learning tool. If the active engine is not the default engine, EDeepLearningTool::SetEnableGPU will be false even if the active device has a GPU device type. Setting EDeepLearningTool::SetEnableGPU to any value when the active engine is not the default one will throw an exception.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetEngine | ( | ) | const |
Sets the engine with which to execute or train the neural network.
| int32_t eVision::EasyDeepLearning::EDeepLearningTool::GetEngineSetupDataBatchSize | ( | ) | const |
Batch size corresponding to the engine data contained in the tool.
| eVision::EasyDeepLearning::EDeepLearningDevice eVision::EasyDeepLearning::EDeepLearningTool::GetEngineSetupDataDevice | ( | ) | const |
Device corresponding to the engine data contained in the tool.
| eVision::EasyDeepLearning::EDeepLearningInferencePrecision eVision::EasyDeepLearning::EDeepLearningTool::GetEngineSetupDataInferencePrecision | ( | ) | const |
Inference precision corresponding to the engine data contained in the tool.
| eVision::EasyDeepLearning::EDeepLearningExecutionSettings eVision::EasyDeepLearning::EDeepLearningTool::GetExecutionSettings | ( | ) | const |
Execution settings of the tool (engine, device(s), inference precision, batch size settings).
| std::vector< uint32_t > eVision::EasyDeepLearning::EDeepLearningTool::GetGPUIndexes | ( | ) | const |
Indexes of the GPUs to use for computations.
Using multiple GPUs is only possible when we can process multiple images at once, i.e. during training or batch inference.
By default, all the detected GPUs will be used.
The GPU are indexed from 0 to EDeepLearningTool::GetNumGPUs - 1.
Use EDeepLearningTool::GetActiveDevice or EDeepLearningTool::GetActiveDevices.
Deprecated in version 23.4. Scheduled to be removed in version 27.6.
| uint64_t eVision::EasyDeepLearning::EDeepLearningTool::GetImageCacheSize | ( | ) | const |
Size in byte of the image cache. The cache is used during training to store reformatted and normalized images. A correctly sized cache can reduce the hard drive accesses and the preprocessing time for each image.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetInferenceModelPath | ( | ) | const |
Path of the inference model when loaded or saved using EDeepLearningTool::SaveInferenceModel, EDeepLearningTool::LoadInferenceModel or EDeepLearningTool::SerializeInferenceModel.
| eVision::EasyDeepLearning::EDeepLearningInferencePrecision eVision::EasyDeepLearning::EDeepLearningTool::GetInferencePrecision | ( | ) | const |
Inference precision.
Use EDeepLearningDevice::IsPrecisionSupported to check whether a device support the given precision.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetLabel | ( | uint32_t | index | ) | const |
Gets the label from its index. If the tool is not trained, the method may throw an exception.
| index | Index of the label |
| eVision::ERGBColor eVision::EasyDeepLearning::EDeepLearningTool::GetLabelColor | ( | uint32_t | index | ) | const |
Label color. The label colors affect how the results will be displayed.
The default label colors are the one specified in the dataset used for training.
| index | Index of the label between 0 and EDeepLearningTool::GetNumLabels |
| uint8_t eVision::EasyDeepLearning::EDeepLearningTool::GetLabelOpacity | ( | uint32_t | index | ) | const |
Gets the label opacity (between 0 for fully transparent and 255 for opaque color). The label opacities affect with the label colors how the results will be displayed.
The default label opacities are the one specified in the dataset used for training.
| index | Index of the label between 0 and EDeepLearningTool::GetNumLabels |
| float eVision::EasyDeepLearning::EDeepLearningTool::GetLabelWeight | ( | uint32_t | index | ) | const |
Gets the label weight. If the tool is not trained, the label weights are not defined. After training, they are set to the value of the training dataset label weights.
| index | Index of the label |
| std::vector< float > eVision::EasyDeepLearning::EDeepLearningTool::GetLearningRateParameters | ( | ) | const |
Parameters of the learning rate.
| eVision::EasyDeepLearning::EDeepLearningLearningRateType eVision::EasyDeepLearning::EDeepLearningTool::GetLearningRateType | ( | ) | const |
Learning rate type.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetNumActiveDevices | ( | ) | const |
Gets the number of devices with which to run or train the model.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetNumAvailableDevices | ( | ) | const |
Available devices for the current EDeepLearningTool::SetEngine.
|
static |
Number of available engines.
| uint32_t eVision::EasyDeepLearning::EDeepLearningTool::GetNumGPUs | ( | ) | const |
Number of detected NVIDIA GPU.
Use EDeepLearningTool::GetNumAvailableDevices or parse the output of EDeepLearningTool::GetAvailableDevices to find the devices that are GPUs.
Deprecated in version 23.4. Scheduled to be removed in version 27.6.
| uint32_t eVision::EasyDeepLearning::EDeepLearningTool::GetNumLabels | ( | ) | const |
Number of labels of this tool. If the tool is not trained, the method will throw an exception.
Some type of tools such as EUnsupervisedSegmenter may have no label at all. For these tools, there is a separate API to control the predicted labels.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetNumPatchesForImage | ( | const eVision::EBaseROI & | sampleImage | ) | const |
Number of patches that will be extracted from an input image to perform inference.
For EasyClassify and EasyLocate, this will always be equal to 1. For EasySegment, the number of patches will depend on the scale, patch size and sampling density parameters.
| sampleImage | Image for which to get the number of patch |
|
virtual |
Number of patches that will be extracted from an input image to perform inference.
For EasyClassify and EasyLocate, this will always be equal to 1. For EasySegment, the number of patches will depend on the scale, patch size and sampling density parameters.
| imageWidth | Width of the image for which to get the number of patch |
| imageHeight | Height of the image for which to get the number of patch |
Reimplemented in eVision::EasyDeepLearning::ESupervisedSegmenter, and eVision::EasyDeepLearning::EUnsupervisedSegmenter.
| uint32_t eVision::EasyDeepLearning::EDeepLearningTool::GetNumTrainedIterations | ( | ) | const |
Number of iterations that were performed to train this deep learning tool.
This number of iteration may result from the addition of the iterations performed in several calls to the training method.
An iteration can also be called an epoch.
| int eVision::EasyDeepLearning::EDeepLearningTool::GetOptimalNumImagesForBatchSize | ( | const eVision::EBaseROI & | sampleImage | ) | const |
Optimal number of images to process together for inference given the batch size and EDeepLearningTool::GetNumPatchesForImage.
In practice, for EasyClassify and EasyLocate, this is the same as the batch size.
For EasySegment, the value will depend on the scale, patch size and sampling density parameters.
| sampleImage | Image for which to get the optimal number of images |
| int eVision::EasyDeepLearning::EDeepLearningTool::GetOptimalNumImagesForBatchSize | ( | int | imageWidth, |
| int | imageHeight ) const |
Optimal number of images to process together for inference given the batch size and EDeepLearningTool::GetNumPatchesForImage.
In practice, for EasyClassify and EasyLocate, this is the same as the batch size.
For EasySegment, the value will depend on the scale, patch size and sampling density parameters.
| imageWidth | Width of the image for which to get the optimal number of images |
| imageHeight | Height of the image for which to get the optimal number of images |
| bool eVision::EasyDeepLearning::EDeepLearningTool::GetOptimizeBatchSize | ( | ) | const |
Indicates whether to optimize the batch size (see EDeepLearningTool::SetBatchSize) to maximize the training and inference speed according to the engine, the device and the available memory.
Default value is true.
The batch size will be optimized at the start of training or during EDeepLearningTool::InitializeInference.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetPath | ( | ) | const |
Path of the tool when loaded or saved using EDeepLearningTool::Save or EDeepLearningTool::Load.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetSettingsPath | ( | ) | const |
Path of the settings when loaded or saved using EDeepLearningTool::SaveSettings, EDeepLearningTool::LoadSettings or EDeepLearningTool::SerializeSettings.
|
pure virtual |
Type of the deep learning tool.
Implemented in eVision::EasyDeepLearning::EClassifier, eVision::EasyDeepLearning::EDeepOCRTool, eVision::EasyDeepLearning::EInterestPointLocator, eVision::EasyDeepLearning::ELocator, eVision::EasyDeepLearning::ESupervisedSegmenter, and eVision::EasyDeepLearning::EUnsupervisedSegmenter.
| std::string eVision::EasyDeepLearning::EDeepLearningTool::GetTrainingModelPath | ( | ) | const |
Path of the training model when loaded or saved using EDeepLearningTool::SaveTrainingModel, EDeepLearningTool::LoadTrainingModel or EDeepLearningTool::SerializeTrainingModel.
| bool eVision::EasyDeepLearning::EDeepLearningTool::HasEngineSetupData | ( | ) | const |
Whether the inference model has engine setup data.
Engine setup data allows for quicker configuration of the engine when reusing the same device, inference precision and batch size.
Use EDeepLearningTool::GetEngineSetupDataDevice, EDeepLearningTool::GetEngineSetupDataInferencePrecision, and EDeepLearningTool::GetEngineSetupDataBatchSize to retrieve the device (and engine), inference precision, and batch size for which the tool has engine setup data.
The engine setup data is stored in the tool after the first inference or after calling EDeepLearningTool::InitializeInference if the engine supports it. At the moment, only the TensorRT engine supports setup data. If you save the tool, the engine setup data will be saved with the tool and can be reused when loading the tool again.
The engine setup data will only be replaced when using another device and/or inference precision and/or batch size with an engine that supports engine setup data. Otherwise, this setup data will remain (for example, using an engine that does not supports setup data will leave the pervious engine setup data intact).
You can clear the engine setup data by using EDeepLearningTool::ClearEngineSetupData.
| bool eVision::EasyDeepLearning::EDeepLearningTool::HasInferenceModel | ( | ) | const |
Whether the inference model is loaded or created when the tool is not yet trained.
| bool eVision::EasyDeepLearning::EDeepLearningTool::HasTrainingModel | ( | ) | const |
Whether the training model is loaded or created when the tool is not yet trained.
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | const eVision::EBaseROI & | img | ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| img | Image for which to prepare the tool for inference |
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | int | width, |
| int | height, | ||
| eVision::EImageType | imageType, | ||
| int | numImages ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| width | Width of the images for which to prepare the tool for inference |
| height | Height of the images for which to prepare the tool for inference |
| imageType | Type of the images for which to prepare the tool for inference |
| numImages | Number of images for which to prepare the tool for inference |
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | std::vector< const eVision::EBaseROI * > & | imgList | ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| imgList | Vector of images for which to prepare the tool for inference |
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | std::vector< eVision::EImageBW16 > & | imgList | ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| imgList | Vector of images for which to prepare the tool for inference |
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | std::vector< eVision::EImageBW8 > & | imgList | ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| imgList | Vector of images for which to prepare the tool for inference |
| void eVision::EasyDeepLearning::EDeepLearningTool::InitializeInference | ( | std::vector< eVision::EImageC24 > & | imgList | ) |
Initializes the neural network for inference (i.e. making predictions with the neural network).
You need to pass an image or a vector of images with the same characteristics (image resolution, image type and number of image) as the image or vector of images that you will use to make inference with this tool.
If EDeepLearningTool::GetOptimizeBatchSize is equal to true, the value of EDeepLearningTool::SetBatchSize will be recomputed.
| imgList | Vector of images for which to prepare the tool for inference |
| bool eVision::EasyDeepLearning::EDeepLearningTool::IsTrained | ( | ) | const |
Tells whether the deep learning tool has been trained.
| bool eVision::EasyDeepLearning::EDeepLearningTool::IsTraining | ( | ) | const |
Indicates whether the object is currently training.
|
virtual |
Loads a deep learning tool. The given ESerializer must have been created for reading.
| filePath | File path. |
|
virtual |
Loads a deep learning tool. The given ESerializer must have been created for reading.
| serializer | Pointer to the ESerializer created for reading. |
| void eVision::EasyDeepLearning::EDeepLearningTool::LoadInferenceModel | ( | const std::string & | filePath | ) |
Loads the tool's inference model. The inference model is required to apply the tool on new images.
| filePath | File path. |
| void eVision::EasyDeepLearning::EDeepLearningTool::LoadSettings | ( | const std::string & | filePath | ) |
Loads the settings of a tool.
| filePath | File path. |
| void eVision::EasyDeepLearning::EDeepLearningTool::LoadTrainingModel | ( | const std::string & | filePath | ) |
Loads the tool's training model. The training model is required to continue a training.
| filePath | File path. |
|
virtual |
Saves the settings, inference and training model of the deep learning tool.
The given ESerializer must have been created for writing.
| filePath | File path. |
|
virtual |
Saves the settings, inference and training model of the deep learning tool.
The given ESerializer must have been created for writing.
| filePath | File path. |
| includeTrainingModel | Whether to save the training model. The training model is required to continue training the tool. |
|
virtual |
Saves the settings, inference and training model of the deep learning tool.
The given ESerializer must have been created for writing.
| serializer | Pointer to the ESerializer created for writing. |
|
virtual |
Saves the settings, inference and training model of the deep learning tool.
The given ESerializer must have been created for writing.
| serializer | Pointer to the ESerializer created for writing. |
| includeTrainingModel | Whether to save the training model. The training model is required to continue training the tool. |
| void eVision::EasyDeepLearning::EDeepLearningTool::SaveInferenceModel | ( | const std::string & | filePath | ) |
Saves the tool's inference model to a file.
| filePath | File path. |
| void eVision::EasyDeepLearning::EDeepLearningTool::SaveSettings | ( | const std::string & | filePath | ) |
Saves the settings of the tool to a file.
| filePath | File path. |
| void eVision::EasyDeepLearning::EDeepLearningTool::SaveTrainingModel | ( | const std::string & | filePath | ) |
Saves the tool's training model to a file.
| filePath | File path. |
| void eVision::EasyDeepLearning::EDeepLearningTool::SerializeInferenceModel | ( | eVision::ESerializer * | serializer | ) |
Serializes the inference model of the tool.
| serializer | Pointer to ESerializer |
|
pure virtual |
Serializes the tool settings.
| serializer | Pointer to ESerializer |
Implemented in eVision::EasyDeepLearning::EClassifier, eVision::EasyDeepLearning::EDeepOCRTool, eVision::EasyDeepLearning::EInterestPointLocator, eVision::EasyDeepLearning::ELocator, eVision::EasyDeepLearning::ELocatorBase, eVision::EasyDeepLearning::ESupervisedSegmenter, and eVision::EasyDeepLearning::EUnsupervisedSegmenter.
| void eVision::EasyDeepLearning::EDeepLearningTool::SerializeTrainingModel | ( | eVision::ESerializer * | serializer | ) |
Serializes the training model of the tool.
The training model is necessary to continue training the tool.
| serializer | Pointer to ESerializer |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetActiveDevice | ( | const eVision::EasyDeepLearning::EDeepLearningDevice & | device | ) |
Sets the device with which to run or train the model.
| device | The device with which to run or train the model. |
For CPU device, the number of thread is initialized from Easy::SetMaxNumberOfProcessingThreads.
Note that this can change EDeepLearningTool::GetInferencePrecision if the previously set value was incompatible with the device.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetActiveDeviceById | ( | int | id | ) |
Sets the device with which to run the model using its index in the list returned by EDeepLearningTool::GetAvailableDevices.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetActiveDeviceByName | ( | const std::string & | name | ) |
Sets the device with which to run the model using its name.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetActiveDevices | ( | const std::vector< eVision::EasyDeepLearning::EDeepLearningDevice > & | devices | ) |
Devices with which to run or train the model.
Only multiple GPUs with the default engine is supported.
| devices | Device |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetActiveDevicesById | ( | const std::vector< int > & | ids | ) |
Sets the devices with which to run the model using their index in the list returned by EDeepLearningTool::GetAvailableDevices.
| ids | Index of the devices between 0 and EDeepLearningTool::GetNumAvailableDevices - 1 |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetAutoSavePeriod | ( | int | period | ) |
Auto-save period. The auto-save period is the number of training iterations between each automatic save of the model.
In order for the model to be automatically saved during the training, the tool must have been loaded or saved to a file. The path where the tool will be saved is either indicated by EDeepLearningTool::GetPath or the three paths EDeepLearningTool::GetSettingsPath, EDeepLearningTool::GetInferenceModelPath, and EDeepLearningTool::GetTrainingModelPath. If one of these path is empty, the corresponding part of the tool will not be saved automatically during training.
By default, auto save is disabled and the period is equal to 0.
| period | New auto-save period. |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetBatchSize | ( | int32_t | size | ) |
Batch size. The batch size is the number of images that are processed together during training and batch inference.
When using multi-GPUs processing (see EDeepLearningTool::SetGPUIndexes), the batch size is the number of images that each GPU will process at once.
A large batch size will increase the processing speed on GPU but also the memory requirements.
The batch size must be bigger or equal to 1 and it is commonly chosen to be a power of 2.
| size | size of the batch |
If EDeepLearningTool::GetOptimizeBatchSize is 'true', then the value of this property will be optimized automatically for training or inference according to the situation.
See also EDeepLearningTool::GetBatchSizeForMaximumInferenceSpeed.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetDeterministicTrainingRandomSeed | ( | int32_t | seed | ) |
Random seed to use when EDeepLearningTool::SetEnableDeterministicTraining is set to true. The default value is 42.
When EDeepLearningTool::SetEnableDeterministicTraining, the random seed is generated using a random non-deterministic source.
| seed | Random seed |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetEnableDeterministicTraining | ( | bool | enable | ) |
Whether to use deterministic training algorithm that allows to repeatable training results. Default value: false.
Deterministic training is not guaranteed when:
| void eVision::EasyDeepLearning::EDeepLearningTool::SetEnableGPU | ( | bool | enable | ) |
Enable the use of a GPU for training and inference of the deep learning tool. If the active engine is not the default engine, EDeepLearningTool::SetEnableGPU will be false even if the active device has a GPU device type. Setting EDeepLearningTool::SetEnableGPU to any value when the active engine is not the default one will throw an exception.
Use EDeepLearningTool::GetActiveDevice.
Deprecated in version 23.4. Scheduled to be removed in version 27.6.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetEngine | ( | const std::string & | engineName | ) |
Sets the engine with which to execute or train the neural network.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetExecutionSettings | ( | const eVision::EasyDeepLearning::EDeepLearningExecutionSettings & | settings | ) |
Execution settings of the tool (engine, device(s), inference precision, batch size settings).
| void eVision::EasyDeepLearning::EDeepLearningTool::SetGPUIndexes | ( | const std::vector< uint32_t > & | indexes | ) |
Indexes of the GPUs to use for computations.
Using multiple GPUs is only possible when we can process multiple images at once, i.e. during training or batch inference.
By default, all the detected GPUs will be used.
| indexes | Indexes of the GPU to use for computations |
The GPU are indexed from 0 to EDeepLearningTool::GetNumGPUs - 1.
Use EDeepLearningTool::GetActiveDevice or EDeepLearningTool::GetActiveDevices.
Deprecated in version 23.4. Scheduled to be removed in version 27.6.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetImageCacheSize | ( | uint64_t | size | ) |
Size in byte of the image cache. The cache is used during training to store reformatted and normalized images. A correctly sized cache can reduce the hard drive accesses and the preprocessing time for each image.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetInferencePrecision | ( | eVision::EasyDeepLearning::EDeepLearningInferencePrecision | prec | ) |
Inference precision.
Use EDeepLearningDevice::IsPrecisionSupported to check whether a device support the given precision.
|
virtual |
Changes a label predicted by the tool.
| index | Index of the label |
| label | New label |
Be careful when changing one of the label of a trained tool. It can create incompatibilities with previous metrics or results computed with this tool or with the dataset used to trained the tool.
Some tools may not use this label API. For example EUnsupervisedSegmenter uses EUnsupervisedSegmenter::SetGoodLabel instead.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetLabelColor | ( | uint32_t | index, |
| const eVision::ERGBColor & | c ) |
Changes a label color.
| index | Index of the label between 0 and EDeepLearningTool::GetNumLabels |
| c | New color for the specified label |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetLabelOpacity | ( | uint32_t | index, |
| uint8_t | opacity ) |
Changes a label opacity (between 0 for fully transparent and 255 for opaque color).
| index | Index of the label between 0 and EDeepLearningTool::GetNumLabels |
| opacity | New opacity for the specified label |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetLabelWeight | ( | uint32_t | index, |
| float | weight ) |
Sets the label weight. If the tool is not trained, the label weights are not defined. After training, they are set to the value of the training dataset label weights.
| index | Index of the label |
| weight | Weight |
| void eVision::EasyDeepLearning::EDeepLearningTool::SetLearningRate | ( | eVision::EasyDeepLearning::EDeepLearningLearningRateType | type, |
| const std::vector< float > & | parameters ) |
Specifies how the value of the learning rate and how it evolves during training.
| void eVision::EasyDeepLearning::EDeepLearningTool::SetOptimizeBatchSize | ( | bool | optimize | ) |
Indicates whether to optimize the batch size (see EDeepLearningTool::SetBatchSize) to maximize the training and inference speed according to the engine, the device and the available memory.
Default value is true.
The batch size will be optimized at the start of training or during EDeepLearningTool::InitializeInference.
| int eVision::EasyDeepLearning::EDeepLearningTool::StopTraining | ( | bool | wait | ) |
Stops training and returns the last completed iteration. If the parameter 'wait' is set to true, the method will wait for the training thread to completely stop. Otherwise, the method will return immediately.
| wait | Whether to wait for the training to completely stop |
| void eVision::EasyDeepLearning::EDeepLearningTool::UnloadInferenceModel | ( | ) |
Unloads the inference model.
| void eVision::EasyDeepLearning::EDeepLearningTool::UnloadModels | ( | ) |
Unloads the inference and training model.
| void eVision::EasyDeepLearning::EDeepLearningTool::UnloadTrainingModel | ( | ) |
Unloads the training model.
| int eVision::EasyDeepLearning::EDeepLearningTool::WaitForIterationCompletion | ( | ) |
Waits until an iteration is complete. A call to this method will block the calling thread until a training iteration in the training thread is finished. This method returns the number of trained iterations.
| int eVision::EasyDeepLearning::EDeepLearningTool::WaitForTrainingCompletion | ( | ) |
Waits until the training is complete or the timeout is expired. A call to this method will block the calling thread for the shortest time between the timeout and the time it takes for the training to complete.
A negative timeout means that the method will wait until the training is complete.
The default value is set to -1.
The method returns the number of trained iterations.
| int eVision::EasyDeepLearning::EDeepLearningTool::WaitForTrainingCompletion | ( | int | timeout | ) |
Waits until the training is complete or the timeout is expired. A call to this method will block the calling thread for the shortest time between the timeout and the time it takes for the training to complete.
A negative timeout means that the method will wait until the training is complete.
The default value is set to -1.
The method returns the number of trained iterations.
| timeout | Timeout in second |
| CppWrapperInternal::WrappedClass eVision::EasyDeepLearning::EDeepLearningTool::wrappedClass_ |