Skip to content

Commit

Permalink
v0.0.4 (#29)
Browse files Browse the repository at this point in the history
* Replace 'Self' type (requires python>=3.11); Add optional revision to hf_hub_download

* Bump version
  • Loading branch information
hubertsiuzdak authored Oct 13, 2023
1 parent 41c7da6 commit 1793fe5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion vocos/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from vocos.pretrained import Vocos


__version__ = "0.0.3"
__version__ = "0.0.4"
10 changes: 5 additions & 5 deletions vocos/pretrained.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from typing import Any, Dict, Self, Tuple, Union
from typing import Any, Dict, Tuple, Union, Optional

import torch
import yaml
Expand Down Expand Up @@ -47,7 +47,7 @@ def __init__(
self.head = head

@classmethod
def from_hparams(cls, config_path: str) -> Self:
def from_hparams(cls, config_path: str) -> Vocos:
"""
Class method to create a new Vocos model instance from hyperparameters stored in a yaml configuration file.
"""
Expand All @@ -60,12 +60,12 @@ def from_hparams(cls, config_path: str) -> Self:
return model

@classmethod
def from_pretrained(cls, repo_id: str) -> Self:
def from_pretrained(cls, repo_id: str, revision: Optional[str] = None) -> Vocos:
"""
Class method to create a new Vocos model instance from a pre-trained model stored in the Hugging Face model hub.
"""
config_path = hf_hub_download(repo_id=repo_id, filename="config.yaml")
model_path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin")
config_path = hf_hub_download(repo_id=repo_id, filename="config.yaml", revision=revision)
model_path = hf_hub_download(repo_id=repo_id, filename="pytorch_model.bin", revision=revision)
model = cls.from_hparams(config_path)
state_dict = torch.load(model_path, map_location="cpu")
if isinstance(model.feature_extractor, EncodecFeatures):
Expand Down

0 comments on commit 1793fe5

Please sign in to comment.