![]() |
ImFusion SDK 4.3
|
#include <AnatomyPlugin/include/ImFusion/AnatomyPlugin/ModelFactory.h>
Factory for managing different versions of ML model sets globally. More...
Factory for managing different versions of ML model sets globally.
Such a model set is a structured collection of (e.g. per-anatomy) ML models. Can be used for customers to override default models in anatomy-specific segmentation and registration algorithms.
Example usages:
Implement modelFactoryInstance() to share a global collection of model sets across instances of a particular class:
Create a customized model set from the default model set by copying and modifying it:
Convenience function for getting the appropriate model path for the ML::Engine passed:
Classes | |
| struct | MLEngine |
| Currently supported ML Engines (cf. ML::Engine) More... | |
| struct | ModelInfo |
| Holds the meta information about a single model. More... | |
| struct | ModelSet |
| List of models. More... | |
Public Types | |
| using | ModelIdentifier = std::string |
| using | MLEngineName = std::string |
Public Member Functions | |
| ModelFactory ()=default | |
| Create a model factory. | |
| ModelFactory & | operator= (const ModelFactory &)=delete |
| ModelFactory & | operator= (ModelFactory &&)=default |
| ModelFactory (ModelFactory &&)=default | |
| ModelFactory | clone () const |
| Create a copy of the current model factory, can be used to assign a model factory (via operator=(ModelFactory&&)) even though the usual assignment operator has been deleted. | |
| void | registerModelSet (const ModelSet &modelSetIn, bool asNewDefault=false) |
| Registers the given ModelSet in the factory. | |
| std::vector< ModelSet::Name > | modelSetNames () const |
| Returns the names of all registered ModelSets. | |
| std::vector< ModelSet::Version > | modelSetVersions (const ModelSet::Name &modelSetName) const |
| Returns the versions of all registered ModelSets with the given ModelSet::Name. | |
| std::shared_ptr< const ModelSet > | modelSet (const ModelSet::Name &modelSetName, const ModelSet::Version &modelSetVersion) const |
| Returns the ModelSet with the given ModelSet::Name and ModelSet::Version if it exists, nullptr otherwise. | |
| std::shared_ptr< const ModelSet > | defaultModelSet () const |
Returns the default ModelSet. nullptr if no model set was registered as default yet. | |
| std::shared_ptr< const ModelSet > | lastRegisteredModelSet () const |
Returns the last registered ModelSet. nullptr if no model set was registered yet. | |
| bool | anyModelAvailable (const ModelIdentifier &modelIdentifier) const |
| Returns true if any model set contains a model with the given identifier. | |
| std::optional< std::string > | modelPath (const ModelSet::Name &modelSetName, const ModelSet::Version &modelSetVersion, const ModelIdentifier &modelIdentifier, const MLEngineName &engineName) const |
| Returns true if the model set contains a model with the given identifier for the given engine. | |
| bool | hasModel (const ModelSet::Name &modelSetName, const ModelSet::Version &modelSetVersion, const ModelIdentifier &modelIdentifier, const MLEngineName &engineName) const |
| Returns true if the model set contains a model with the given identifier for the given engine. | |
| std::unique_ptr< ML::MachineLearningModel > | createModel (const ModelSet::Name &modelSetName, const ModelSet::Version &modelSetVersion, const ModelIdentifier &modelIdentifier, const MLEngineName &engineName, bool verbose=true) const |
| Convenience function to fetch model information from the factory and directly instantiate it using the ML plugin. | |
| void registerModelSet | ( | const ModelSet & | modelSetIn, |
| bool | asNewDefault = false ) |
Registers the given ModelSet in the factory.
A potentially existing ModelSet with the same ModelSet::Name and ModelSet::Version combination is overridden. To set the model set as the new default (cf. defaultModelSet()) pass true for asNewDefault.
|
nodiscard |
Convenience function to fetch model information from the factory and directly instantiate it using the ML plugin.
Returns nullptr if the model is not stored in the ModelFactory or the ML engine is not configured correctly.