civitai download validate name

This commit is contained in:
Vladimir Mandic
2024-06-15 16:31:55 -04:00
parent 68e7692ed5
commit 6c1d59d367
5 changed files with 15 additions and 6 deletions
+5 -3
View File
@@ -24,10 +24,12 @@ force_diffusers = [
'c2ec22757b46', # flash-sd15
]
def check_override(shorthash):
def check_override(shorthash=''):
force = False
force = force or (shared.sd_model_type == 'sd3') # TODO sd3 forced diffusers for lora load
if len(shorthash) < 4:
return False
force = any(x.startswith(shorthash) for x in maybe_diffusers) if shared.opts.lora_maybe_diffusers else False
return force
force = force or (any(x.startswith(shorthash) for x in maybe_diffusers) if shared.opts.lora_maybe_diffusers else False)
force = force or any(x.startswith(shorthash) for x in force_diffusers)
if force and shared.opts.lora_maybe_diffusers:
shared.log.debug('LoRA override: force diffusers')
+4 -1
View File
@@ -87,7 +87,10 @@ def load_diffusers(name, network_on_disk, lora_scale=1.0) -> network.Network:
return cached
if not shared.native:
return None
shared.sd_model.load_lora_weights(network_on_disk.filename)
try:
shared.sd_model.load_lora_weights(network_on_disk.filename)
except Exception as e:
errors.display(e, "LoRA")
if shared.opts.lora_fuse_diffusers:
shared.sd_model.fuse_lora(lora_scale=lora_scale)
net = network.Network(name, network_on_disk)
+4
View File
@@ -152,6 +152,10 @@ def download_civit_model_thread(model_name, model_url, model_path, model_type, t
def download_civit_model(model_url: str, model_name: str, model_path: str, model_type: str, token: str = None):
import threading
if model_name is None or len(model_name) == 0:
err = 'Model download: no target model name provided'
shared.log.error(err)
return err
thread = threading.Thread(target=download_civit_model_thread, args=(model_name, model_url, model_path, model_type, token))
thread.start()
return f'Model download: name={model_name} url={model_url} path={model_path}'
+1 -1
View File
@@ -431,7 +431,7 @@ def create_ui():
r = req(url)
log.debug(f'CivitAI search: name="{name}" tag={tag or "none"} url="{url}" status={r.status_code}')
if r.status_code != 200:
return [], [], []
return [], gr.update(visible=False, value=[]), gr.update(visible=False, value=None), gr.update(visible=False, value=None)
body = r.json()
nonlocal data
data = body.get('items', [])
+1 -1
Submodule wiki updated: 0db3587f44...23dc2fc800