John6666 commited on
Commit
ddeb3f3
·
verified ·
1 Parent(s): 5be865f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +28 -26
app.py CHANGED
@@ -536,32 +536,34 @@ def run_lora(prompt, image_input, image_strength, cfg_scale, steps, selected_ind
536
  print("Prompt Mash: ", prompt_mash) #
537
 
538
  # Load LoRA weights with respective scales
539
- with calculateDuration("Loading LoRA weights"):
540
- for idx, lora in enumerate(selected_loras):
541
- lora_name = f"lora_{idx}"
542
- lora_names.append(lora_name)
543
- print(f"Lora Name: {lora_name}")
544
- lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
545
- lora_path = lora['repo']
546
- weight_name = lora.get("weights")
547
- print(f"Lora Path: {lora_path}")
548
- if image_input is not None:
549
- pipe_i2i.load_lora_weights(
550
- lora_path,
551
- weight_name=weight_name if weight_name else None,
552
- low_cpu_mem_usage=True,
553
- adapter_name=lora_name,
554
- token=HF_TOKEN
555
- )
556
- else:
557
- pipe.load_lora_weights(
558
- lora_path,
559
- weight_name=weight_name if weight_name else None,
560
- low_cpu_mem_usage=True,
561
- adapter_name=lora_name,
562
- token=HF_TOKEN
563
- )
564
- print("Loaded LoRAs:", lora_names)
 
 
565
  if image_input is not None:
566
  pipe_i2i.set_adapters(lora_names, adapter_weights=lora_weights)
567
  else:
 
536
  print("Prompt Mash: ", prompt_mash) #
537
 
538
  # Load LoRA weights with respective scales
539
+ if selected_indices:
540
+ with calculateDuration("Loading LoRA weights"):
541
+ for idx, lora in enumerate(selected_loras):
542
+ lora_name = f"lora_{idx}"
543
+ lora_names.append(lora_name)
544
+ print(f"Lora Name: {lora_name}")
545
+ lora_weights.append(lora_scale_1 if idx == 0 else lora_scale_2)
546
+ lora_path = lora['repo']
547
+ weight_name = lora.get("weights")
548
+ print(f"Lora Path: {lora_path}")
549
+ if image_input is not None:
550
+ pipe_i2i.load_lora_weights(
551
+ lora_path,
552
+ weight_name=weight_name if weight_name else None,
553
+ low_cpu_mem_usage=True,
554
+ adapter_name=lora_name,
555
+ token=HF_TOKEN
556
+ )
557
+ else:
558
+ pipe.load_lora_weights(
559
+ lora_path,
560
+ weight_name=weight_name if weight_name else None,
561
+ low_cpu_mem_usage=True,
562
+ adapter_name=lora_name,
563
+ token=HF_TOKEN
564
+ )
565
+ print("Loaded LoRAs:", lora_names)
566
+ if selected_indices or is_valid_lora(lora_json):
567
  if image_input is not None:
568
  pipe_i2i.set_adapters(lora_names, adapter_weights=lora_weights)
569
  else: