ImFusion C++ SDK 4.4.0
ImFusion::ModelsManager Namespace Reference

Contains functionality for downloading ML models from a server and caching them on disk. More...

Detailed Description

Contains functionality for downloading ML models from a server and caching them on disk.

Classes

struct  ModelInfo

Typedefs

using Json = nlohmann::json
using ErrorMessage = std::string

Functions

std::vector< Utils::Expected< ModelInfo, ErrorMessage > > listLocalModels (const Filesystem::Directory &modelsDirectory, Progress *progress=nullptr)
 Lists all cached models that are contained in the given directory.
Utils::Expected< std::vector< ModelInfo >, std::stringlistRemoteModels (Progress *progress=nullptr)
 Lists all models that are available on the server.
std::optional< ErrorMessage > downloadModel (const ModelInfo &modelInfo, const Filesystem::Directory &destination, Progress *progress=nullptr)
 Downloads a model from the server and caches it in the given folder (created if not existing).
bool updateModelsJsonToLatest (const Filesystem::Directory &modelsDirectory, Progress *progress=nullptr)
std::optional< int > modelsJsonVersion (const Filesystem::Directory &modelsDirectory)

Function Documentation

◆ listLocalModels()

std::vector< Utils::Expected< ModelInfo, ErrorMessage > > ImFusion::ModelsManager::listLocalModels ( const Filesystem::Directory & modelsDirectory,
Progress * progress = nullptr )

Lists all cached models that are contained in the given directory.

If a model cannot be loaded, an error is added to the list, but the search continues.

◆ listRemoteModels()

Utils::Expected< std::vector< ModelInfo >, std::string > ImFusion::ModelsManager::listRemoteModels ( Progress * progress = nullptr)

Lists all models that are available on the server.

Returns an error if the server doesn't answer or the response cannot be parsed.

◆ downloadModel()

std::optional< ErrorMessage > ImFusion::ModelsManager::downloadModel ( const ModelInfo & modelInfo,
const Filesystem::Directory & destination,
Progress * progress = nullptr )

Downloads a model from the server and caches it in the given folder (created if not existing).

Downloads both the model config file and the model binary file. Both files are named according to their filenames in modelInfo. Any existing files with those names will be overwritten! The model will not be downloaded if the config cannot be downloaded first. Likewise the config is deleted again if the model cannot be downloaded.

Search Tab / S to search, Esc to close