### Install development version from GitHub Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Clone the repository and synchronize the environment using uv. ```bash git git@github.com:audeering/audmodel.git cd audmodel uv sync ``` -------------------------------- ### Install audmodel via pip Source: https://github.com/audeering/audmodel/blob/main/docs/installation.rst Run this command to install the audmodel package. ```bash $ pip install audmodel ``` -------------------------------- ### Model directory structure Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Example of a model folder structure containing the model file, configuration, and logs. ```text root_v2/ model.onnx model.yaml readme.txt log/ eval.yaml ``` -------------------------------- ### Enable pre-commit hooks locally Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Install and run pre-commit hooks to ensure code quality before commits. ```bash uvx pre-commit install uvx pre-commit run --all-files ``` -------------------------------- ### Test audmodel interactively with uvx Source: https://github.com/audeering/audmodel/blob/main/docs/installation.rst Run this command to launch an interactive ipython session with audmodel installed. ```bash $ uvx --with audmodel ipython ``` -------------------------------- ### Get latest model version Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Retrieve the most recent version string for a model. ```pycon >>> audmodel.latest_version(uid) '2.0.0' ``` -------------------------------- ### Retrieve model name Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Get the name associated with a model ID. ```pycon >>> audmodel.name(uid) 'onnx' ``` -------------------------------- ### Retrieve model meta fields Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Get the metadata dictionary for a specific model ID. ```pycon >>> audmodel.meta(uid) {'model': {'cnn10': {'learning-rate': 0.01, 'optimizer': 'adam'}}, 'data': {'emodb': {'version': '1.1.1'}, 'msppodcast': {'version': '2.6.0'}}, 'feature': {'melspec': {'win_dur': '32ms', 'hop_dur': '10ms', 'mel_bins': 64}}} ``` -------------------------------- ### Retrieve model parameters Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Get the parameters dictionary for a specific model ID. ```pycon >>> audmodel.parameters(uid) {'model': 'cnn10', 'data': ['emodb', 'msppodcast'], 'feature': 'melspec', 'sampling_rate': 16000} ``` -------------------------------- ### Build documentation with Sphinx Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Generate HTML documentation from the docs directory. ```bash uv run python -m sphinx docs/ build/html -b html ``` -------------------------------- ### Check documentation links Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Verify that all links within the documentation are valid. ```bash uv run python -m sphinx docs/ build/html -b linkcheck ``` -------------------------------- ### Configure a local repository Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Sets up a local temporary repository on the file system for storing models, overriding the default S3 repository configuration. ```python import audeer import audmodel repo = "models" host = audeer.path("./tmp/repo") audeer.mkdir(audeer.path(host, repo)) repository = audmodel.Repository(repo, host, "file-system") audmodel.config.REPOSITORIES = [repository] ``` -------------------------------- ### Configure S3 credentials in minio.cfg Source: https://github.com/audeering/audmodel/blob/main/docs/authentication.rst Add these credentials to ~/.config/audbackend/minio.cfg to grant write access to repositories like audmodel-public. ```cfg [s3.dualstack.eu-north-1.amazonaws.com] access_key = MY_ACCESS_KEY secret_key = MY_SECRET_KEY ``` -------------------------------- ### Load a model Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Load the model into a local directory and inspect the resulting file structure. ```python model_root = audmodel.load(uid) ``` ```text 1.0.0/ model.onnx model.yaml readme.txt log/ eval.yaml ``` -------------------------------- ### Run ruff and codespell manually Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Execute linting and formatting tools directly on the project files. ```bash uvx ruff check --fix . # lint all Python files, and fix any fixable errors uvx ruff format . # format code of all Python files uvx codespell ``` -------------------------------- ### Access REPOSITORIES configuration Source: https://github.com/audeering/audmodel/blob/main/docs/configuration.rst Access the list of configured repositories via audmodel.config. ```pycon >>> audmodel.config.REPOSITORIES [Repository('audmodel-public', 's3.dualstack.eu-north-1.amazonaws.com', 's3')] ``` -------------------------------- ### Default configuration file structure Source: https://github.com/audeering/audmodel/blob/main/docs/configuration.rst The default settings for audmodel, which can be overridden by a ~/.config/audmodel.yaml file. ```yaml cache_root: ~/audmodel repositories: - name: audmodel-public host: s3.dualstack.eu-north-1.amazonaws.com backend: s3 ``` -------------------------------- ### List model versions Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Retrieve all published versions for a given model UID. ```pycon >>> audmodel.versions(uid) ['1.0.0', '2.0.0'] ``` -------------------------------- ### Run ruff and codespell on specific folders Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Restrict linting and spelling checks to specific directories. ```bash uvx ruff check audmodel/ tests/ uvx codespell audmodel/ tests/ ``` -------------------------------- ### Run tests with pytest Source: https://github.com/audeering/audmodel/blob/main/CONTRIBUTING.rst Execute the project test suite. ```bash uv run pytest ``` -------------------------------- ### audmodel.load(uid) Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Loads a model from the backend and returns the path to the model root directory. ```APIDOC ## audmodel.load(uid) ### Description Downloads or retrieves the model files associated with the given UID or alias and returns the local path to the model root directory. ### Parameters - **uid** (str) - Required - The unique identifier or alias of the model. ``` -------------------------------- ### Export S3 credentials as environment variables Source: https://github.com/audeering/audmodel/blob/main/docs/authentication.rst Alternatively, set these environment variables to authenticate for repository access. ```bash export MINIO_ACCESS_KEY="MY_ACCESS_KEY" export MINIO_SECRET_KEY="MY_SECRET_KEY" ``` -------------------------------- ### List model cache sub-folders Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Lists the unique sub-folders within the model cache directory, structured as /. ```pycon >>> audeer.list_dir_names(cache_root, basenames=True) ['3e120e8d'] ``` -------------------------------- ### Define model arguments Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Defines the required metadata arguments such as name, parameters, version, author, meta information, and subgroup for the model. ```python name = "onnx" params = { "model": "cnn10", "data": ["emodb", "msppodcast"], "feature": "melspec", "sampling_rate": 16000, } version = "1.0.0" author = "sphinx" meta = { "model": { "cnn10": { "learning-rate": 1e-2, "optimizer": "adam", }, }, "data": { "emodb": {"version": "1.1.1"}, "msppodcast": {"version": "2.6.0"}, }, "feature": { "melspec": { "win_dur": "32ms", "hop_dur": "10ms", "mel_bins": 64, }, }, } subgroup = "emotion.cnn" ``` -------------------------------- ### Publish a new model version Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Use audmodel.publish to register a new version of an existing model. ```pycon >>> uid_v1 = uid >>> uid = audmodel.publish( ... root_v2, ... name, ... params, ... "2.0.0", ... meta=meta, ... subgroup=subgroup, ... repository=repository, ... ) >>> uid '3e120e8d-2.0.0' ``` -------------------------------- ### Publish the model Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Publishes the model using the defined arguments and repository, returning a unique model ID. ```pycon >>> uid = audmodel.publish( ... root_v1, ... name, ... params, ... version, ... author=author, ... meta=meta, ... subgroup=subgroup, ... repository=repository, ... ) >>> uid '3e120e8d-1.0.0' ``` -------------------------------- ### Access CACHE_ROOT configuration Source: https://github.com/audeering/audmodel/blob/main/docs/configuration.rst Access the default cache root path via audmodel.config. ```pycon >>> audmodel.config.CACHE_ROOT '~/audmodel' ``` -------------------------------- ### Set cache root via environment variable Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Changes the location of the cache folder by setting the AUDMODEL_CACHE_ROOT environment variable. ```bash export AUDMODEL_CACHE_ROOT=/path/to/your/cache ``` -------------------------------- ### Check default cache root Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Retrieves the default path where models are unpacked. ```python cache_root = audmodel.default_cache_root() ``` -------------------------------- ### Verify alias updates Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Check the aliases associated with the old and new model UIDs to confirm the update. ```pycon >>> audmodel.aliases(uid_v1) [] ``` ```pycon >>> audmodel.aliases(uid) ['emotion-production', 'emotion-small'] ``` -------------------------------- ### Load model using alias Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Load a model using its alias instead of the model ID. ```python model_root = audmodel.load("emotion-small") ``` -------------------------------- ### Set cache root via configuration Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Changes the location of the cache folder by modifying the audmodel.config.CACHE_ROOT attribute. ```python audmodel.config.CACHE_ROOT = "/path/to/your/cache" ``` -------------------------------- ### Update model aliases Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Point existing model aliases to the new version UID. ```python audmodel.set_alias("emotion-small", uid) audmodel.set_alias("emotion-production", uid) ``` -------------------------------- ### Check model existence Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Verify if a model exists using its unique identifier. ```pycon >>> audmodel.exists(uid) True ``` -------------------------------- ### List model aliases Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Inspect all aliases currently associated with a model ID. ```pycon >>> audmodel.aliases(uid) ['emotion-production', 'emotion-small'] ``` -------------------------------- ### Modify CACHE_ROOT at runtime Source: https://github.com/audeering/audmodel/blob/main/docs/configuration.rst Update the cache root path dynamically using audmodel.config. ```pycon >>> audmodel.config.CACHE_ROOT = "/user/cache" >>> audmodel.config.CACHE_ROOT '/user/cache' ``` -------------------------------- ### audmodel.exists(uid) Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Checks if a model with the specified unique identifier exists. ```APIDOC ## audmodel.exists(uid) ### Description Checks if a model exists in the backend using its unique identifier. ### Parameters - **uid** (str) - Required - The unique identifier of the model. ``` -------------------------------- ### Add additional model alias Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Assign a second alias to the same model ID. ```python audmodel.set_alias("emotion-production", uid) ``` -------------------------------- ### Replace model metadata with audmodel.update_meta Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Replaces the entire metadata of a model by setting the replace parameter to True. ```pycon >>> meta = {"new": "meta"} >>> audmodel.update_meta(uid, meta, replace=True) {'new': 'meta'} ``` -------------------------------- ### Set model alias Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Assign an alias to a model ID. ```python audmodel.set_alias("emotion-small", uid) ``` -------------------------------- ### Update model metadata for a new version Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Modify the feature extractor configuration in the meta dictionary before publishing a new version. ```python meta["feature"]["melspec"]["mel_bins"] = 32 ``` -------------------------------- ### Resolve model alias Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Retrieve the model ID associated with a specific alias. ```pycon >>> audmodel.resolve_alias("emotion-small") '3e120e8d-1.0.0' ``` -------------------------------- ### audmodel.set_alias(alias, uid) Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Assigns an alias to a specific model ID. ```APIDOC ## audmodel.set_alias(alias, uid) ### Description Creates or updates an alias to point to a specific model ID. ### Parameters - **alias** (str) - Required - The alias name to assign. - **uid** (str) - Required - The unique identifier of the model. ``` -------------------------------- ### Update model metadata with audmodel.update_meta Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Updates or adds fields to a model's metadata by passing a dictionary. This method supports nested fields. ```pycon >>> meta = { ... "model": { ... "cnn10": {"layers": 10}, ... }, ... } >>> audmodel.update_meta(uid, meta) {'model': {'cnn10': {'learning-rate': 0.01, 'optimizer': 'adam', 'layers': 10}}, 'data': {'emodb': {'version': '1.1.1'}, 'msppodcast': {'version': '2.6.0'}}, 'feature': {'melspec': {'win_dur': '32ms', 'hop_dur': '10ms', 'mel_bins': 32}}} ``` -------------------------------- ### audmodel.resolve_alias(alias) Source: https://github.com/audeering/audmodel/blob/main/docs/usage.rst Resolves an alias to its corresponding model ID. ```APIDOC ## audmodel.resolve_alias(alias) ### Description Returns the model ID associated with the provided alias. Requires backend access. ### Parameters - **alias** (str) - Required - The alias to resolve. ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.