multimodalart HF staff commited on
Commit
f93fac7
1 Parent(s): 8120649

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -3
app.py CHANGED
@@ -265,6 +265,7 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
265
  lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
266
  lora_path = lora['repo']
267
  weight_name = lora.get("weights")
 
268
  if image_input is not None:
269
  if weight_name:
270
  pipe_i2i.load_lora_weights(lora_path, weight_name=weight_name, low_cpu_mem_usage=True, adapter_name=lora_name)
@@ -359,19 +360,19 @@ def add_custom_lora(custom_lora, selected_indices):
359
  existing_item_index = next((index for (index, item) in enumerate(loras) if item['repo'] == repo), None)
360
  if existing_item_index is None:
361
  if(repo.endswith(".safetensors") and repo.startswith("http")):
362
- downloaded_path = download_file(repo)
363
 
364
  new_item = {
365
  "image": image if image is not None else "",
366
  "title": title,
367
- "repo": downloaded_path,
368
  "weights": path,
369
  "trigger_word": trigger_word
370
  }
371
  print(f"New LoRA: {new_item}")
372
  existing_item_index = len(loras)
373
  loras.append(new_item)
374
-
375
  # Update gallery
376
  gallery_items = [(item["image"], item["title"]) for item in loras]
377
  # Update selected_indices if there's room
@@ -395,6 +396,7 @@ def add_custom_lora(custom_lora, selected_indices):
395
  lora2 = loras[selected_indices[1]]
396
  selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}]({lora2['repo']}) ✨"
397
  lora_image_2 = lora2['image']
 
398
  return (
399
  gr.update(value=gallery_items),
400
  selected_info_1,
 
265
  lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
266
  lora_path = lora['repo']
267
  weight_name = lora.get("weights")
268
+ print(f"Lora Path: {lora_path}")
269
  if image_input is not None:
270
  if weight_name:
271
  pipe_i2i.load_lora_weights(lora_path, weight_name=weight_name, low_cpu_mem_usage=True, adapter_name=lora_name)
 
360
  existing_item_index = next((index for (index, item) in enumerate(loras) if item['repo'] == repo), None)
361
  if existing_item_index is None:
362
  if(repo.endswith(".safetensors") and repo.startswith("http")):
363
+ repo = download_file(repo)
364
 
365
  new_item = {
366
  "image": image if image is not None else "",
367
  "title": title,
368
+ "repo": repo,
369
  "weights": path,
370
  "trigger_word": trigger_word
371
  }
372
  print(f"New LoRA: {new_item}")
373
  existing_item_index = len(loras)
374
  loras.append(new_item)
375
+
376
  # Update gallery
377
  gallery_items = [(item["image"], item["title"]) for item in loras]
378
  # Update selected_indices if there's room
 
396
  lora2 = loras[selected_indices[1]]
397
  selected_info_2 = f"### LoRA 2 Selected: [{lora2['title']}]({lora2['repo']}) ✨"
398
  lora_image_2 = lora2['image']
399
+ print("Chegou no final")
400
  return (
401
  gr.update(value=gallery_items),
402
  selected_info_1,