aboutsummaryrefslogtreecommitdiffstats
path: root/modules/hypernetworks/ui.py
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2022-10-21 13:51:01 +0000
committerGitHub <noreply@github.com>2022-10-21 13:51:01 +0000
commitec37f8a45f316db8a20445aa80afd602457327b0 (patch)
tree20a59fe67602feeff3ba6e023f823a314294e78e /modules/hypernetworks/ui.py
parent003d2c7fe427edde299274c9e0d5fa59734e7f7e (diff)
parent85cb5918ee7c97cafafe4149880ed82f1933d919 (diff)
downloadstable-diffusion-webui-gfx803-ec37f8a45f316db8a20445aa80afd602457327b0.tar.gz
stable-diffusion-webui-gfx803-ec37f8a45f316db8a20445aa80afd602457327b0.tar.bz2
stable-diffusion-webui-gfx803-ec37f8a45f316db8a20445aa80afd602457327b0.zip
Merge branch 'master' into features-to-readme
Diffstat (limited to 'modules/hypernetworks/ui.py')
-rw-r--r--modules/hypernetworks/ui.py19
1 files changed, 15 insertions, 4 deletions
diff --git a/modules/hypernetworks/ui.py b/modules/hypernetworks/ui.py
index dfa599af..266f04f6 100644
--- a/modules/hypernetworks/ui.py
+++ b/modules/hypernetworks/ui.py
@@ -1,5 +1,6 @@
import html
import os
+import re
import gradio as gr
@@ -9,11 +10,21 @@ from modules import sd_hijack, shared, devices
from modules.hypernetworks import hypernetwork
-def create_hypernetwork(name, enable_sizes):
+def create_hypernetwork(name, enable_sizes, overwrite_old, layer_structure=None, add_layer_norm=False, activation_func=None):
fn = os.path.join(shared.cmd_opts.hypernetwork_dir, f"{name}.pt")
- assert not os.path.exists(fn), f"file {fn} already exists"
-
- hypernet = modules.hypernetworks.hypernetwork.Hypernetwork(name=name, enable_sizes=[int(x) for x in enable_sizes])
+ if not overwrite_old:
+ assert not os.path.exists(fn), f"file {fn} already exists"
+
+ if type(layer_structure) == str:
+ layer_structure = [float(x.strip()) for x in layer_structure.split(",")]
+
+ hypernet = modules.hypernetworks.hypernetwork.Hypernetwork(
+ name=name,
+ enable_sizes=[int(x) for x in enable_sizes],
+ layer_structure=layer_structure,
+ add_layer_norm=add_layer_norm,
+ activation_func=activation_func,
+ )
hypernet.save(fn)
shared.reload_hypernetworks()