fix loading hypernetwork

This commit is contained in:
Vladimir Mandic
2023-09-15 11:53:14 -04:00
parent 2309398be8
commit b67e986ec3
2 changed files with 7 additions and 4 deletions
+3 -3
View File
@@ -221,10 +221,10 @@ class Hypernetwork:
torch.save(optimizer_saved_dict, f"{filename}.optim")
def load(self, filename):
self.filename = filename
self.filename = filename if os.path.exists(filename) else os.path.join(shared.opts.hypernetwork_dir, filename)
if self.name is None:
self.name = os.path.splitext(os.path.basename(filename))[0]
with progress.open(filename, 'rb', description=f'Loading hypernetwork: [cyan]{filename}', auto_refresh=True, console=shared.console) as f:
self.name = os.path.splitext(os.path.basename(self.filename))[0]
with progress.open(self.filename, 'rb', description=f'Loading hypernetwork: [cyan]{self.filename}', auto_refresh=True, console=shared.console) as f:
state_dict = torch.load(f, map_location='cpu')
self.layer_structure = state_dict.get('layer_structure', [1, 2, 1])
self.optional_info = state_dict.get('optional_info', None)