![]() |
ImFusion SDK 4.3
|
#include <ImFusion/ML/ModelConfiguration.h>
Configuration class for MachineLearningModel parameters. More...
Configuration class for MachineLearningModel parameters.
This class parses YAML configuration files and validates their consistency. It supports versioned configurations to maintain API compatibility.
Version Management:
Public Member Functions | |
ModelConfiguration (const std::string &configFilePath, PredictionOutput defaultPredictionOutput=PredictionOutput::Unknown) | |
const std::string & | configPath () const |
bool | save (const std::string &outputYamlPath) const |
Save model configuration to YAML file. | |
void | configure (const Properties *properties) override |
Configure this object instance by de-serializing the given Properties. | |
void | configuration (Properties *properties) const override |
Serialize the current object configuration into the given Properties object. | |
bool | ok () const |
Status | status () const |
bool | mustSplitImage () const |
const std::string & | logDomain () const |
bool | compareWith (const ModelConfiguration &other, bool ignoreVersion=false) const |
bool | operator== (const ModelConfiguration &other) const |
bool | operator!= (const ModelConfiguration &other) const |
int | upgradedVersion () const |
int | originalVersion () const |
int | version () const |
const std::string & | name () const |
const std::string & | description () const |
const std::string & | modelPath () const |
const std::string & | engine () const |
ModelType | modelType () const |
const std::vector< PredictionType > & | predictionTypes () const |
const std::vector< PredictionOutput > & | predictionOutputTypes () const |
const std::vector< std::string > & | preprocessingInputFields () const |
const std::vector< std::string > & | engineInputFields () const |
const std::vector< std::string > & | engineOutputFields () const |
const std::vector< std::string > & | engineOutputFieldsToIgnore () const |
const std::map< std::string, std::vector< std::string > > & | labelNames () const |
bool | verbose () const |
int | maxBatchSize () const |
std::optional< int > | ringBufferSize () const |
bool | forceCPU () const |
void | setForceCPU (bool forceCPU) |
const std::vector< Operation::Specs > & | getPreProcessingOptions () const |
const std::vector< Operation::Specs > & | getPostProcessingOptions () const |
Properties | getSamplingParameters () const |
std::vector< Operation::Specs > & | getPreProcessingOptions () |
std::vector< Operation::Specs > & | getPostProcessingOptions () |
Properties | getEngineProperties () const |
bool | skipUnpadding () const |
bool | mustCloneInputContainer () const |
![]() | |
virtual void | configureDefaults () |
Retrieve the properties of this object, replaces values with their defaults and sets it again. | |
void | registerParameter (ParameterBase *param) |
Register the given Parameter or SubProperty, so that it will be configured during configure()/configuration(). | |
void | unregisterParameter (const ParameterBase *param) |
Remove the given Parameter or SubProperty from the list of registered parameters. | |
Configurable (const Configurable &rhs) | |
Configurable (Configurable &&rhs) noexcept | |
Configurable & | operator= (const Configurable &) |
Configurable & | operator= (Configurable &&) noexcept |
Public Attributes | |
ModelParameter< int > | p_version = {"Version", 1, this, ParamRequired::Yes} |
Version of the config yaml. | |
ModelParameter< std::string > | p_name = {"Name", "", this, ParamRequired::No} |
Name of the model. | |
ModelParameter< std::string > | p_description = {"Description", "", this, ParamRequired::No} |
Description of the model. | |
ModelParameter< ModelType > | p_modelType |
Type of model. Parameter name: "Type", default value: "NeuralNetwork", required: Yes. | |
ModelParameter< bool > | p_verbose = {"Verbose", false, this, ParamRequired::No} |
Toggle verbosity. | |
ModelParameter< int > | p_maxBatchSize = {"MaxBatchSize", 1, this, ParamRequired::No} |
Control the maximum number of input items the model is processing in each forward pass. | |
ModelParameter< bool > | p_cloneInputContainer = {"CloneInputContainer", false, this, ParamRequired::No} |
Whether the model must create an output with the exact same type of the input For pixelwise predictions, the output will have the same type as the input if this flag is true. | |
ModelParameter< std::optional< int > > | p_ringBufferSize = {"RingBufferSize", std::optional<int>{}, this, ParamRequired::No} |
Control the number of frames the model is batching from a stream. | |
ModelParameter< bool > | p_commercialUseAllowed = {"CommercialUseAllowed", true, this, ParamRequired::No} |
Commercial use flag. | |
ModelParameter< bool > | p_upgradeMLModelV2 = {"UpgradeToMLModelV2", false, this, ParamRequired::No} |
Controls whether the model configuration should be upgraded to the latest version (V8). | |
std::vector< PredictionType > | p_predictionTypes = {} |
Types of prediction of each model head. Yaml config keyword: "PredictionType". | |
std::vector< PredictionOutput > | p_predictionOutputs = {} |
Output prediction types of each model head. Yaml config keyword: "PredictionOutput". | |
ModelParameter< std::vector< std::string > > | p_preprocessingInputFields |
Input fields of the preprocessing. | |
std::map< std::string, std::vector< std::string > > | p_labelNames |
Label names of each model head. Yaml config keyword: "LabelNames". | |
std::vector< Operation::Specs > | p_preprocessing = {} |
Configuration of the preprocessing. Yaml config keyword: "PreProcessing". | |
std::vector< Operation::Specs > | p_postprocessing = {} |
Configuration of the postprocessing. Yaml config keyword: "PostProcessing". | |
EngineConfiguration | engineConfig |
Configuration of the Engine parameters. Yaml config keyword: "Engine". | |
SamplingConfiguration | samplingConfig |
Configuration of the Sampling parameters. Yaml config keyword: "Sampling". | |
Properties | p_acknowledgments |
Acknowledgments. Yaml config keyword: "Acknowledgments". | |
![]() | |
Signal | signalParametersChanged |
Emitted whenever one of the registered Parameters' or SubPropertys' signalValueChanged signal was emitted. | |
Static Public Attributes | |
static constexpr const int | VERSION_COUNT = 8 |
Latest version of the ModelConfiguration class. | |
static constexpr const int | LAST_V1_VERSION = 7 |
Last version of the ModelConfiguration class that supports MachineLearningModel V1. | |
static const std::string | p_defaultInputName |
static const std::string | p_defaultOutputName |
Additional Inherited Members | |
![]() | |
std::vector< Param > | m_params |
List of all registered Parameter and SubProperty instances. | |
bool save | ( | const std::string & | outputYamlPath | ) | const |
Save model configuration to YAML file.
This can be useful for converting an old configuration to the latest version.
|
overridevirtual |
Configure this object instance by de-serializing the given Properties.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.
|
overridevirtual |
Serialize the current object configuration into the given Properties object.
The default implementation will do so automatically for all registered Parameter and SubProperty instances.
Reimplemented from Configurable.
int version | ( | ) | const |
const std::string & name | ( | ) | const |
const std::string & description | ( | ) | const |
const std::string & modelPath | ( | ) | const |
const std::string & engine | ( | ) | const |
ModelType modelType | ( | ) | const |
const std::vector< PredictionType > & predictionTypes | ( | ) | const |
const std::vector< PredictionOutput > & predictionOutputTypes | ( | ) | const |
const std::vector< std::string > & preprocessingInputFields | ( | ) | const |
const std::vector< std::string > & engineInputFields | ( | ) | const |
const std::vector< std::string > & engineOutputFields | ( | ) | const |
const std::vector< std::string > & engineOutputFieldsToIgnore | ( | ) | const |
const std::map< std::string, std::vector< std::string > > & labelNames | ( | ) | const |
bool verbose | ( | ) | const |
int maxBatchSize | ( | ) | const |
std::optional< int > ringBufferSize | ( | ) | const |
bool forceCPU | ( | ) | const |
void setForceCPU | ( | bool | forceCPU | ) |
const std::vector< Operation::Specs > & getPreProcessingOptions | ( | ) | const |
const std::vector< Operation::Specs > & getPostProcessingOptions | ( | ) | const |
Properties getSamplingParameters | ( | ) | const |
std::vector< Operation::Specs > & getPreProcessingOptions | ( | ) |
std::vector< Operation::Specs > & getPostProcessingOptions | ( | ) |
Properties getEngineProperties | ( | ) | const |
bool skipUnpadding | ( | ) | const |
bool mustCloneInputContainer | ( | ) | const |
|
staticconstexpr |
Last version of the ModelConfiguration class that supports MachineLearningModel V1.
MachineLearningModel V2 introduces a new logic for splitting the input image into patches and recombining the predictions. This improves the efficiency and the stability of the model predictions, but may also introduce changes that could affect model predictions.
ModelParameter<bool> p_cloneInputContainer = {"CloneInputContainer", false, this, ParamRequired::No} |
Whether the model must create an output with the exact same type of the input For pixelwise predictions, the output will have the same type as the input if this flag is true.
If false, the output must be exactly a SharedImageSet.
ModelParameter<std::optional<int> > p_ringBufferSize = {"RingBufferSize", std::optional<int>{}, this, ParamRequired::No} |
Control the number of frames the model is batching from a stream.
This attribute is used only by PixelwiseLearningStream for models trained on a buffer of images (needs special treatment by the class)
ModelParameter<bool> p_upgradeMLModelV2 = {"UpgradeToMLModelV2", false, this, ParamRequired::No} |
Controls whether the model configuration should be upgraded to the latest version (V8).
When set to true, the configuration will be automatically upgraded to the latest available version during parsing, even if the original version is 7 or lower. This enables new features and improvements but may introduce changes in the splitting/recombination logic that could affect model predictions.
Default is false to maintain backward compatibility and avoid potential regressions in existing models.
ModelParameter<std::vector<std::string> > p_preprocessingInputFields |
Input fields of the preprocessing.
|
static |
|
static |