Model management for Dala ML.
Handles model download, caching, compilation, and versioning. Models are stored in the app's private directory and can be hot-swapped without app restart.
Usage
# Download a model from URL
{:ok, model_info} = Dala.ML.Model.download("https://example.com/model.mlmodel")
# List cached models
models = Dala.ML.Model.cached_models()
# Get model path for loading
path = Dala.ML.Model.path("my_model")
# Delete a cached model
:ok = Dala.ML.Model.delete("my_model")
Summary
Functions
Returns the directory where models are cached.
Returns the total size of all cached models in bytes.
Returns a list of cached model info maps.
Clears all cached models.
Compiles a CoreML model (.mlmodel → .mlmodelc) for faster loading.
Deletes a cached model.
Downloads a model from a URL and caches it locally.
Returns the local path for a cached model by name.
Functions
@spec cache_dir() :: String.t()
Returns the directory where models are cached.
@spec cache_size() :: non_neg_integer()
Returns the total size of all cached models in bytes.
@spec cached_models() :: [map()]
Returns a list of cached model info maps.
@spec clear_cache() :: :ok
Clears all cached models.
Compiles a CoreML model (.mlmodel → .mlmodelc) for faster loading.
Only relevant on iOS. On other platforms, returns the path unchanged.
Deletes a cached model.
Downloads a model from a URL and caches it locally.
Options
:name— Custom name for the model (defaults to filename from URL):checksum— Expected SHA256 checksum for verification:force— Overwrite existing cached model (default: false)
Returns the local path for a cached model by name.