diff --git a/pyannote/audio/core/model.py b/pyannote/audio/core/model.py index ceaca92e..4c3f6e16 100644 --- a/pyannote/audio/core/model.py +++ b/pyannote/audio/core/model.py @@ -726,6 +726,7 @@ class Model(pl.LightningModule): strict: bool = True, task: Task = None, use_auth_token: Union[Text, None] = None, + cache_dir: Union[Path, Text] = CACHE_DIR, **kwargs, ) -> "Model": """Load pretrained model @@ -757,6 +758,9 @@ class Model(pl.LightningModule): When loading a private huggingface.co model, set `use_auth_token` to True or to a string containing your hugginface.co authentication token that can be obtained by running `huggingface-cli login` + cache_dir: Path or str, optional + Path to model cache directory. Defaults to content of PYANNOTE_CACHE + environment variable, or "~/.cache/torch/pyannote" when unset. kwargs: optional Any extra keyword args needed to init the model. Can also be used to override saved hyperparameter values. @@ -800,7 +804,7 @@ class Model(pl.LightningModule): url=url, library_name="pyannote", library_version=__version__, - cache_dir=CACHE_DIR, + cache_dir=cache_dir, use_auth_token=use_auth_token, ) diff --git a/pyannote/audio/core/pipeline.py b/pyannote/audio/core/pipeline.py index e24f5c9d..a68c36ae 100644 --- a/pyannote/audio/core/pipeline.py +++ b/pyannote/audio/core/pipeline.py @@ -48,6 +48,7 @@ class Pipeline(_Pipeline): batch_size: int = 32, use_auth_token: Union[Text, None] = None, progress_hook: bool = False, + cache_dir: Union[Path, Text] = CACHE_DIR, ) -> "Pipeline": """Load pretrained pipeline @@ -68,6 +69,9 @@ class Pipeline(_Pipeline): progress_hook : bool, optional Set to True to display a tqdm progress bar for each `Inference` preprocessor. + cache_dir: Path or str, optional + Path to model cache directory. Defaults to content of PYANNOTE_CACHE + environment variable, or "~/.cache/torch/pyannote" when unset. """ if device is not None: @@ -91,7 +95,7 @@ class Pipeline(_Pipeline): url=url, library_name="pyannote", library_version=__version__, - cache_dir=CACHE_DIR, + cache_dir=cache_dir, use_auth_token=use_auth_token, )