linoyts HF Staff commited on
Commit
de3f8ed
·
verified ·
1 Parent(s): 88bb35e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -8
app.py CHANGED
@@ -159,16 +159,15 @@ def infer_with_lora(input_image, prompt, selected_index, custom_lora, seed=42, r
159
  lora_path = load_lora_weights(lora_to_use["repo"], lora_to_use["weights"])
160
  if lora_path:
161
  pipe.load_lora_weights(lora_path, adapter_name="selected_lora")
 
 
162
  current_lora = lora_to_use
163
-
164
 
165
  except Exception as e:
166
  print(f"Error loading LoRA: {e}")
167
  # Continue without LoRA
168
-
169
- # Set LoRA scale if LoRA is loaded
170
- if current_lora and hasattr(pipe, 'set_adapters'):
171
- pipe.set_adapters("selected_lora", adapter_weights=[lora_scale])
172
 
173
  input_image = input_image.convert("RGB")
174
  # Add trigger word to prompt
@@ -237,10 +236,9 @@ with gr.Blocks(css="custom.css") as demo:
237
  with gr.Row(elem_id="main_app"):
238
  with gr.Column(scale=4, elem_id="box_column"):
239
  with gr.Group(elem_id="gallery_box"):
240
- input_image = gr.Image(label="Upload image for editing", type="pil", height=250)
241
 
242
  gallery = gr.Gallery(
243
- [(item["image"], item["title"]) for item in flux_loras_raw],
244
  label="Pick a LoRA",
245
  allow_preview=False,
246
  columns=3,
@@ -278,7 +276,7 @@ with gr.Blocks(css="custom.css") as demo:
278
  minimum=0,
279
  maximum=2,
280
  step=0.1,
281
- value=1.0,
282
  info="Controls the strength of the LoRA effect"
283
  )
284
  seed = gr.Slider(
 
159
  lora_path = load_lora_weights(lora_to_use["repo"], lora_to_use["weights"])
160
  if lora_path:
161
  pipe.load_lora_weights(lora_path, adapter_name="selected_lora")
162
+ pipe.set_adapters(["selected_lora"], adapter_weights=[lora_scale])
163
+ print(f"loaded: {lora_path} with scale {lora_scale}")
164
  current_lora = lora_to_use
 
165
 
166
  except Exception as e:
167
  print(f"Error loading LoRA: {e}")
168
  # Continue without LoRA
169
+ else:
170
+ print(f"using already loaded lora: {lora_to_use}")
 
 
171
 
172
  input_image = input_image.convert("RGB")
173
  # Add trigger word to prompt
 
236
  with gr.Row(elem_id="main_app"):
237
  with gr.Column(scale=4, elem_id="box_column"):
238
  with gr.Group(elem_id="gallery_box"):
239
+ input_image = gr.Image(label="Upload a picture of yourself", type="pil", height=300)
240
 
241
  gallery = gr.Gallery(
 
242
  label="Pick a LoRA",
243
  allow_preview=False,
244
  columns=3,
 
276
  minimum=0,
277
  maximum=2,
278
  step=0.1,
279
+ value=1.5,
280
  info="Controls the strength of the LoRA effect"
281
  )
282
  seed = gr.Slider(