Commit 2d006ce1 authored by Milly's avatar Milly Committed by AUTOMATIC1111

xy_grid: Find hypernetwork by closest name

parent 4aeacaef
......@@ -120,6 +120,17 @@ def load_hypernetwork(filename):
shared.loaded_hypernetwork = None
def find_closest_hypernetwork_name(search: str):
if not search:
return None
search = search.lower()
applicable = [name for name in shared.hypernetworks if search in name.lower()]
if not applicable:
return None
applicable = sorted(applicable, key=lambda name: len(name))
return applicable[0]
def apply_hypernetwork(hypernetwork, context, layer=None):
hypernetwork_layers = (hypernetwork.layers if hypernetwork is not None else {}).get(context.shape[2], None)
......
......@@ -84,7 +84,11 @@ def apply_checkpoint(p, x, xs):
def apply_hypernetwork(p, x, xs):
hypernetwork.load_hypernetwork(x)
if x.lower() in ["", "none"]:
name = None
else:
name = hypernetwork.find_closest_hypernetwork_name(x)
hypernetwork.load_hypernetwork(name)
def apply_clip_skip(p, x, xs):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment