aboutsummaryrefslogtreecommitdiff
path: root/modules/hypernetworks/ui.py
diff options
context:
space:
mode:
authordiscus0434 <discus0434@gmail.com>2022-10-22 11:14:46 +0000
committerdiscus0434 <discus0434@gmail.com>2022-10-22 11:14:46 +0000
commitdcb45dfecfd0d7f2c268343d8a83fd33c276345b (patch)
tree001c8ebf9e0c7af692ae1237142206f568ff6903 /modules/hypernetworks/ui.py
parent0e8ca8e7af05be22d7d2c07a47c3c7febe0f0ab6 (diff)
parent50b5504401e50b6c94eba41b37fe212b2f27b792 (diff)
Merge branch 'master' of upstream
Diffstat (limited to 'modules/hypernetworks/ui.py')
-rw-r--r--modules/hypernetworks/ui.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/modules/hypernetworks/ui.py b/modules/hypernetworks/ui.py
index 5f6f17b6..2b472d87 100644
--- a/modules/hypernetworks/ui.py
+++ b/modules/hypernetworks/ui.py
@@ -9,9 +9,13 @@ from modules import devices, sd_hijack, shared
from modules.hypernetworks import hypernetwork
-def create_hypernetwork(name, enable_sizes, layer_structure=None, activation_func=None, add_layer_norm=False, use_dropout=False):
+def create_hypernetwork(name, enable_sizes, overwrite_old, layer_structure=None, activation_func=None, add_layer_norm=False, use_dropout=False):
+ # Remove illegal characters from name.
+ name = "".join( x for x in name if (x.isalnum() or x in "._- "))
+
fn = os.path.join(shared.cmd_opts.hypernetwork_dir, f"{name}.pt")
- assert not os.path.exists(fn), f"file {fn} already exists"
+ 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(",")]