Spaces:
Runtime error
Runtime error
Commit
•
fac3a9f
1
Parent(s):
a3b5cab
Update app.py
Browse files
app.py
CHANGED
@@ -450,25 +450,21 @@ def get_civitai_safetensors(link):
|
|
450 |
return model_data["name"], f"{lora_archive}/{safetensors_name}", trigger_word, image_url
|
451 |
|
452 |
def check_custom_model(link):
|
453 |
-
|
454 |
-
if(link.startswith("https://")):
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
return get_huggingface_safetensors(link)
|
462 |
-
except Exception as e:
|
463 |
-
print("Error: ", e)
|
464 |
-
return None, None, None, None
|
465 |
|
466 |
def show_loading_widget():
|
467 |
return gr.update(visible=True)
|
468 |
|
469 |
def load_custom_lora(link):
|
470 |
-
|
471 |
-
|
472 |
card = f'''
|
473 |
<div class="custom_lora_card">
|
474 |
<span>Loaded custom LoRA:</span>
|
@@ -482,13 +478,10 @@ def load_custom_lora(link):
|
|
482 |
</div>
|
483 |
'''
|
484 |
return gr.update(visible=True), card, gr.update(visible=True), [path, trigger_word], gr.Gallery(selected_index=None), f"Custom: {path}"
|
485 |
-
|
486 |
gr.Warning("Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content")
|
487 |
return gr.update(visible=True), "Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content", gr.update(visible=False), None, gr.update(visible=True), gr.update(visible=True)
|
488 |
-
|
489 |
-
# gr.Info("Invalid custom LoRA")
|
490 |
-
# return gr.update(visible=True), "Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content", gr.update(visible=False), None, gr.update(visible=True), gr.update(visible=True)
|
491 |
-
|
492 |
def remove_custom_lora():
|
493 |
return "", gr.update(visible=False), gr.update(visible=False), None
|
494 |
with gr.Blocks(css="custom.css") as demo:
|
|
|
450 |
return model_data["name"], f"{lora_archive}/{safetensors_name}", trigger_word, image_url
|
451 |
|
452 |
def check_custom_model(link):
|
453 |
+
if(link.startswith("https://")):
|
454 |
+
if(link.startswith("https://huggingface.co") or link.startswith("https://www.huggingface.co")):
|
455 |
+
link_split = link.split("huggingface.co/")
|
456 |
+
return get_huggingface_safetensors(link_split[1])
|
457 |
+
elif(link.startswith("https://civitai.com") or link.startswith("https://www.civitai.com")):
|
458 |
+
return get_civitai_safetensors(link)
|
459 |
+
else:
|
460 |
+
return get_huggingface_safetensors(link)
|
|
|
|
|
|
|
|
|
461 |
|
462 |
def show_loading_widget():
|
463 |
return gr.update(visible=True)
|
464 |
|
465 |
def load_custom_lora(link):
|
466 |
+
try:
|
467 |
+
title, path, trigger_word, image = check_custom_model(link)
|
468 |
card = f'''
|
469 |
<div class="custom_lora_card">
|
470 |
<span>Loaded custom LoRA:</span>
|
|
|
478 |
</div>
|
479 |
'''
|
480 |
return gr.update(visible=True), card, gr.update(visible=True), [path, trigger_word], gr.Gallery(selected_index=None), f"Custom: {path}"
|
481 |
+
except Exception as e:
|
482 |
gr.Warning("Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content")
|
483 |
return gr.update(visible=True), "Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content", gr.update(visible=False), None, gr.update(visible=True), gr.update(visible=True)
|
484 |
+
|
|
|
|
|
|
|
485 |
def remove_custom_lora():
|
486 |
return "", gr.update(visible=False), gr.update(visible=False), None
|
487 |
with gr.Blocks(css="custom.css") as demo:
|