publish()¶
- audmodel.publish(root, name, params, version, *, author=None, date=None, meta=None, repository=Repository('models-local', 'https://artifactory.audeering.com/artifactory', 'artifactory'), subgroup=None, verbose=False)[source]¶
Zip model and publish as a new artifact.
Before publishing a model, pick meaningful values for
name
,subgroup
,params
. The following table explains what the arguments should encode and shows examples.Encodes
Examples
name
package used to train/create the model
onnx
sklearn
torch
subgroup
project
task the model was trained for
model architecture
ser.dimensions.wav2vec2
age.cnn
params
model
data
feature set
sampling rate
{ ‘model’: ‘facebook/wav2vec2-large’, ‘data’: ‘msppodcast’, ‘sampling_rate’: 16000 }
{ ‘model’: ‘cnn10’, ‘data’: [‘agender’, ‘emodb’], ‘feature’: ‘log-melspec’, ‘sampling_rate’: 8000 }
The
meta
argument encodes additional information. In contrast toname
,subgroup
,params
it can be changed later. It should be used to extend information of theparams
entries using the same keys. In addition, it can store example output, and benchmark results. For example, ameta
entry corresponding to the firstparams
example from the table might contain:{ 'model': {'facebook/wav2vec2-large': {'layers': 24}}, 'data': {'msppodcast': {'version': '2.6.0'}}, }
- Parameters
root (
str
) – folder with model filesname (
str
) – model nameversion (
str
) – version stringauthor (
Optional
[str
]) – author name(s), defaults to user namemeta (
Optional
[dict
[str
,object
]]) – dictionary with meta informationrepository (
Repository
) – repository where the model will be publishedsubgroup (
Optional
[str
]) – subgroup under which the model is stored on backend..
are replaced by/
on the backendverbose (
bool
) – show debug messages
- Return type
- Returns
unique model ID
- Raises
audbackend.BackendError – if connection to repository on backend cannot be established
RuntimeError – if a model with same UID exists already
RuntimeError – if an unexpected error occurs during publishing
RuntimeError – if
meta
orparams
cannot be serialized to a YAML fileValueError – if subgroup is set to
'_uid'
FileNotFoundError – if
root
folder cannot be found
Examples
>>> # Assuming your model files are stored under `model_root` >>> # and your repository is given by `repository` >>> # (which you usually don't specify, but use its default value) >>> import datetime >>> name = "torch" >>> subgroup = "audmodel.dummy.cnn" >>> version = "4.0.0" >>> author = "Calvin and Hobbes" >>> data = datetime.date(1985, 11, 18) >>> params = { ... "model": "cnn10", ... "data": "emodb", ... "feature": "melspec", ... "sampling_rate": 16000, ... } >>> meta = { ... "model": { ... "cnn10": { ... "learning-rate": 1e-4, ... "optimizer": "sgd", ... }, ... }, ... "data": { ... "emodb": { ... "version": "1.2.0", ... }, ... }, ... "feature": { ... "melspec": { ... "win_dur": "32ms", ... "hop_dur": "10ms", ... "num_fft": 512, ... "mel_bins": 64, ... }, ... }, ... } >>> publish( ... model_root, ... name, ... params, ... version, ... author=author, ... date=date, ... meta=meta, ... subgroup=subgroup, ... repository=repository, ... ) 'd4e9c65b-4.0.0'