Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -202,10 +202,6 @@ def center_crop_image_as_square(img):
|
|
202 |
|
203 |
img_cropped = img.crop((left, top, right, bottom))
|
204 |
return img_cropped
|
205 |
-
|
206 |
-
def check_selected(selected_state):
|
207 |
-
if not selected_state:
|
208 |
-
raise gr.Error("You must select a style")
|
209 |
|
210 |
def merge_incompatible_lora(full_path_lora, lora_scale):
|
211 |
for weights_file in [full_path_lora]:
|
@@ -309,11 +305,14 @@ def generate_image(prompt, negative, face_emb, face_image, face_kps, image_stren
|
|
309 |
|
310 |
return image
|
311 |
|
312 |
-
def run_lora(face_image, prompt, negative,
|
313 |
# get the lora and its default values
|
314 |
lora = getLoraByRepoName(lora_repo_name)
|
315 |
default_values = getLoraDefaultsByRepoName(lora_repo_name)
|
316 |
|
|
|
|
|
|
|
317 |
st = time.time()
|
318 |
|
319 |
face_image = readb64(face_image)
|
@@ -350,9 +349,6 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
350 |
if negative == "":
|
351 |
negative = None
|
352 |
|
353 |
-
if not selected_state:
|
354 |
-
raise gr.Error("You must select a LoRA")
|
355 |
-
|
356 |
weight_name = lora["weights"]
|
357 |
|
358 |
full_path_lora = state_dicts[lora["repo"]]["saved_name"]
|
@@ -364,7 +360,7 @@ def run_lora(face_image, prompt, negative, lora_scale, selected_state, face_stre
|
|
364 |
|
365 |
st = time.time()
|
366 |
|
367 |
-
image = generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, lora, full_path_lora,
|
368 |
|
369 |
image_base64 = writeb64(image)
|
370 |
|
@@ -389,7 +385,7 @@ with gr.Blocks() as demo:
|
|
389 |
negative = gr.Textbox(label="Negative Prompt")
|
390 |
|
391 |
# initial value was 0.9
|
392 |
-
|
393 |
|
394 |
# initial value was 0.85
|
395 |
face_strength = gr.Slider(0, 1, value=0.75, step=0.01, label="Face strength", info="Higher values increase the face likeness but reduce the creative liberty of the models")
|
@@ -411,7 +407,7 @@ with gr.Blocks() as demo:
|
|
411 |
input_image_base64,
|
412 |
prompt,
|
413 |
negative,
|
414 |
-
|
415 |
face_strength,
|
416 |
image_strength,
|
417 |
guidance_scale,
|
|
|
202 |
|
203 |
img_cropped = img.crop((left, top, right, bottom))
|
204 |
return img_cropped
|
|
|
|
|
|
|
|
|
205 |
|
206 |
def merge_incompatible_lora(full_path_lora, lora_scale):
|
207 |
for weights_file in [full_path_lora]:
|
|
|
305 |
|
306 |
return image
|
307 |
|
308 |
+
def run_lora(face_image, prompt, negative, lora_weight, face_strength, image_strength, guidance_scale, depth_control_scale, lora_repo_name):
|
309 |
# get the lora and its default values
|
310 |
lora = getLoraByRepoName(lora_repo_name)
|
311 |
default_values = getLoraDefaultsByRepoName(lora_repo_name)
|
312 |
|
313 |
+
if not lora_repo_name:
|
314 |
+
raise gr.Error("You must input a LoRA repo name")
|
315 |
+
|
316 |
st = time.time()
|
317 |
|
318 |
face_image = readb64(face_image)
|
|
|
349 |
if negative == "":
|
350 |
negative = None
|
351 |
|
|
|
|
|
|
|
352 |
weight_name = lora["weights"]
|
353 |
|
354 |
full_path_lora = state_dicts[lora["repo"]]["saved_name"]
|
|
|
360 |
|
361 |
st = time.time()
|
362 |
|
363 |
+
image = generate_image(prompt, negative, face_emb, face_image, face_kps, image_strength, guidance_scale, face_strength, depth_control_scale, lora, full_path_lora, lora_weight, st)
|
364 |
|
365 |
image_base64 = writeb64(image)
|
366 |
|
|
|
385 |
negative = gr.Textbox(label="Negative Prompt")
|
386 |
|
387 |
# initial value was 0.9
|
388 |
+
lora_weight = gr.Slider(0, 10, value=6, step=0.1, label="LoRA weight")
|
389 |
|
390 |
# initial value was 0.85
|
391 |
face_strength = gr.Slider(0, 1, value=0.75, step=0.01, label="Face strength", info="Higher values increase the face likeness but reduce the creative liberty of the models")
|
|
|
407 |
input_image_base64,
|
408 |
prompt,
|
409 |
negative,
|
410 |
+
lora_weight,
|
411 |
face_strength,
|
412 |
image_strength,
|
413 |
guidance_scale,
|