Spaces:
Runtime error
Runtime error
Commit
·
45e04f6
1
Parent(s):
a9d44b5
wip
Browse files
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 |
-
|
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 !=
|
320 |
-
if
|
321 |
pipe.disable_lora()
|
322 |
pipe.unfuse_lora()
|
323 |
pipe.unload_lora_weights()
|
324 |
-
print(f"Unloaded LoRA: {
|
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 |
-
|
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}"
|