yonishafir commited on
Commit
45e04f6
·
1 Parent(s): a9d44b5
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -164,7 +164,7 @@ def make_canny_condition(image, min_val=100, max_val=200, w_bilateral=True):
164
  default_negative_prompt = "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
165
 
166
  # Global variable to track the currently loaded LoRA
167
- current_lora_name = None
168
 
169
  # Load face detection and recognition package
170
  app = FaceAnalysis(name='antelopev2', root='./', providers=['CPUExecutionProvider'])
@@ -316,12 +316,12 @@ def generate_image(image_path, prompt, num_steps, guidance_scale, seed, num_imag
316
  # print("Using LoRA: ", lora_name)
317
 
318
 
319
- if lora_name != current_lora_name: # Check if LoRA needs to be changed
320
- if current_lora_name is not None: # If a LoRA is already loaded, unload it
321
  pipe.disable_lora()
322
  pipe.unfuse_lora()
323
  pipe.unload_lora_weights()
324
- print(f"Unloaded LoRA: {current_lora_name}")
325
 
326
  if lora_name != "": # Load the new LoRA if specified
327
  lora_path = os.path.join(lora_base_path, lora_name, "pytorch_lora_weights.safetensors")
@@ -334,7 +334,7 @@ def generate_image(image_path, prompt, num_steps, guidance_scale, seed, num_imag
334
  print(f"Loaded new LoRA: {lora_name}")
335
 
336
  # Update the current LoRA name
337
- current_lora_name = lora_name
338
 
339
  if lora_name != "":
340
  full_prompt = f"{lora_prefix} {prompt}"
 
164
  default_negative_prompt = "Logo,Watermark,Text,Ugly,Morbid,Extra fingers,Poorly drawn hands,Mutation,Blurry,Extra limbs,Gross proportions,Missing arms,Mutated hands,Long neck,Duplicate,Mutilated,Mutilated hands,Poorly drawn face,Deformed,Bad anatomy,Cloned face,Malformed limbs,Missing legs,Too many fingers"
165
 
166
  # Global variable to track the currently loaded LoRA
167
+ CURRENT_LORA_NAME = None
168
 
169
  # Load face detection and recognition package
170
  app = FaceAnalysis(name='antelopev2', root='./', providers=['CPUExecutionProvider'])
 
316
  # print("Using LoRA: ", lora_name)
317
 
318
 
319
+ if lora_name != CURRENT_LORA_NAME: # Check if LoRA needs to be changed
320
+ if CURRENT_LORA_NAME is not None: # If a LoRA is already loaded, unload it
321
  pipe.disable_lora()
322
  pipe.unfuse_lora()
323
  pipe.unload_lora_weights()
324
+ print(f"Unloaded LoRA: {CURRENT_LORA_NAME}")
325
 
326
  if lora_name != "": # Load the new LoRA if specified
327
  lora_path = os.path.join(lora_base_path, lora_name, "pytorch_lora_weights.safetensors")
 
334
  print(f"Loaded new LoRA: {lora_name}")
335
 
336
  # Update the current LoRA name
337
+ CURRENT_LORA_NAME = lora_name
338
 
339
  if lora_name != "":
340
  full_prompt = f"{lora_prefix} {prompt}"