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
+4 -1
View File
@@ -187,7 +187,10 @@ function setupExtraNetworksForTab(tabname) {
const intersectionObserver = new IntersectionObserver((entries) => {
if (!en) return;
for (const el of Array.from(gradioApp().querySelectorAll('.extra-networks-page'))) el.style.height = `${window.opts.extra_networks_height}vh`;
for (const el of Array.from(gradioApp().querySelectorAll('.extra-networks-page'))) {
el.style.height = `${window.opts.extra_networks_height}vh`;
el.parentElement.style.width = '-webkit-fill-available';
}
if (entries[0].intersectionRatio > 0) {
if (window.opts.extra_networks_card_cover === 'cover') {
en.style.transition = '';
+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)