Skip to content

Commit

Permalink
Added another check to enable or disable strict loading on the state_…
Browse files Browse the repository at this point in the history
…dict when necessary.
  • Loading branch information
ZeroCool940711 committed Sep 9, 2023
1 parent c007058 commit 1e63779
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion muse_maskgit_pytorch/muse_maskgit_pytorch.py
Original file line number Diff line number Diff line change
Expand Up @@ -470,7 +470,10 @@ def load(self, path):
if not path.exists() and path.is_file():
raise ValueError(f"cannot find file {path} (does not exist or is not a file)")
state_dict = torch.load(str(path), map_location="cpu")
self.load_state_dict(state_dict)
try:
self.load_state_dict(state_dict)
except RuntimeError:
self.load_state_dict(state_dict, strict=False)

def print(self, *args, **kwargs):
return self.accelerator.print(*args, **kwargs) if self.accelerator else print(*args, **kwargs)
Expand Down

0 comments on commit 1e63779

Please sign in to comment.