fix for torch 1.12.1 loading saved file from torch 1.11

This commit is contained in:
AUTOMATIC 2022-09-02 01:31:01 +03:00
parent d5dfbc45a6
commit 6970696789
1 changed files with 2 additions and 0 deletions

View File

@ -730,6 +730,8 @@ class StableDiffusionModelHijack:
data = torch.load(path)
param_dict = data['string_to_param']
if hasattr(param_dict, '_parameters'):
param_dict = getattr(param_dict, '_parameters') # fix for torch 1.12.1 loading saved file from torch 1.11
assert len(param_dict) == 1, 'embedding file has multiple terms in it'
emb = next(iter(param_dict.items()))[1].reshape(768)
self.word_embeddings[name] = emb