multimodalart HF staff commited on
Commit
6b83f3e
1 Parent(s): 743097a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +21 -18
app.py CHANGED
@@ -458,25 +458,28 @@ def show_loading_widget():
458
  return gr.update(visible=True)
459
 
460
  def load_custom_lora(link):
461
- try:
462
- title, path, trigger_word, image = check_custom_model(link)
463
- card = f'''
464
- <div class="custom_lora_card">
465
- <span>Loaded custom LoRA:</span>
466
- <div class="card_internal">
467
- <img src="{image}" />
468
- <div>
469
- <h3>{title}</h3>
470
- <small>{"Using: <code><b>"+trigger_word+"</code></b> as the trigger word" if trigger_word else "No trigger word found. If there's a trigger word, include it in your prompt"}<br></small>
 
 
 
471
  </div>
472
- </div>
473
- </div>
474
- '''
475
- return gr.update(visible=True), card, gr.update(visible=True), [path, trigger_word], gr.Gallery(selected_index=None), f"Custom: {path}"
476
- except Exception as e:
477
- gr.Warning("Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content")
478
- 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)
479
-
480
  def remove_custom_lora():
481
  return "", gr.update(visible=False), gr.update(visible=False), None
482
  with gr.Blocks(css="custom.css") as demo:
 
458
  return gr.update(visible=True)
459
 
460
  def load_custom_lora(link):
461
+ if(link):
462
+ try:
463
+ title, path, trigger_word, image = check_custom_model(link)
464
+ card = f'''
465
+ <div class="custom_lora_card">
466
+ <span>Loaded custom LoRA:</span>
467
+ <div class="card_internal">
468
+ <img src="{image}" />
469
+ <div>
470
+ <h3>{title}</h3>
471
+ <small>{"Using: <code><b>"+trigger_word+"</code></b> as the trigger word" if trigger_word else "No trigger word found. If there's a trigger word, include it in your prompt"}<br></small>
472
+ </div>
473
+ </div>
474
  </div>
475
+ '''
476
+ return gr.update(visible=True), card, gr.update(visible=True), [path, trigger_word], gr.Gallery(selected_index=None), f"Custom: {path}"
477
+ except Exception as e:
478
+ gr.Warning("Invalid LoRA: either you entered an invalid link, a non-SDXL LoRA or a LoRA with mature content")
479
+ 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)
480
+ else:
481
+ return gr.update(visible=False), "", gr.update(visible=False), None, gr.update(visible=True), gr.update(visible=True)
482
+
483
  def remove_custom_lora():
484
  return "", gr.update(visible=False), gr.update(visible=False), None
485
  with gr.Blocks(css="custom.css") as demo: