Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Handling wrong checkpoint #90

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion fs2/cli/synthesize.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,16 @@ def synthesize( # noqa: C901

# Load checkpoints
print(f"Loading checkpoint from {model_path}", file=sys.stderr)
model: FastSpeech2 = FastSpeech2.load_from_checkpoint(model_path).to(device) # type: ignore

from pydantic import ValidationError

try:
model: FastSpeech2 = FastSpeech2.load_from_checkpoint(model_path).to(device) # type: ignore
except (TypeError, ValidationError) as e:
# TODO: should we print the following message only if there are more than X validation errors?
# e.error_count() > X
logger.error(f"Unable to load {model_path}: {e}")
sys.exit(1)
model.eval()

# get global step
Expand Down
11 changes: 10 additions & 1 deletion fs2/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,16 @@ def __init__(
""" """
super().__init__()
if not isinstance(config, FastSpeech2Config):
config = FastSpeech2Config(**config)
from pydantic import ValidationError

try:
config = FastSpeech2Config(**config)
except ValidationError as e:
logger.error(f"{e}")
raise TypeError(
"Unable to load config. Possible causes: is it really a FastSpeech2Config? or the correct version?"
)

if stats is not None and not isinstance(stats, Stats):
stats = Stats(**stats)
self.config = config
Expand Down