vilarin commited on
Commit
b37d7c8
1 Parent(s): 37205d0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -8
app.py CHANGED
@@ -59,13 +59,16 @@ def scrape_lora_link(url):
59
  return None
60
 
61
  def enable_lora(lora_scale, lora_in, lora_add):
62
- if load_in:
63
- lora_add = load_in
64
- url = f'https://huggingface.co/{lora_add}/tree/main'
65
- lora_name = scrape_lora_link(url)
66
- pipe.load_lora_weights(lora_add, weight_name=lora_name)
67
- pipe.fuse_lora(lora_scale=lora_scale)
68
- pipe.to(device="cuda", dtype=torch.bfloat16)
 
 
 
69
 
70
  @spaces.GPU()
71
  def generate_image(
@@ -207,7 +210,7 @@ with gr.Blocks(css=CSS, js=JS, theme="Nymbo/Nymbo_Theme") as demo:
207
  value=1.0,
208
  )
209
  lora_in = gr.Dropdown(
210
- choice=["Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration", "Shakker-Labs/AWPortrait-FL", ""],
211
  label="LoRA Model",
212
  info="Load the LoRA",
213
  value="Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration",
 
59
  return None
60
 
61
  def enable_lora(lora_scale, lora_in, lora_add):
62
+ if not lora_in and not lora_add:
63
+ return
64
+ else:
65
+ if load_in:
66
+ lora_add = load_in
67
+ url = f'https://huggingface.co/{lora_add}/tree/main'
68
+ lora_name = scrape_lora_link(url)
69
+ pipe.load_lora_weights(lora_add, weight_name=lora_name)
70
+ pipe.fuse_lora(lora_scale=lora_scale)
71
+ pipe.to(device="cuda", dtype=torch.bfloat16)
72
 
73
  @spaces.GPU()
74
  def generate_image(
 
210
  value=1.0,
211
  )
212
  lora_in = gr.Dropdown(
213
+ choices=["Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration", "Shakker-Labs/AWPortrait-FL", ""],
214
  label="LoRA Model",
215
  info="Load the LoRA",
216
  value="Shakker-Labs/FLUX.1-dev-LoRA-blended-realistic-illustration",