Update app.py
Browse files
app.py
CHANGED
|
@@ -116,18 +116,28 @@ def run_lora(input_image, prompt, cfg_scale, steps, selected_index, randomize_se
|
|
| 116 |
if randomize_seed:
|
| 117 |
seed = random.randint(0, MAX_SEED)
|
| 118 |
|
| 119 |
-
image_generator = generate_image(input_image, prompt_mash, steps, seed, cfg_scale, lora_scale, progress)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 120 |
|
| 121 |
-
# Consume the generator to get the final image
|
| 122 |
-
final_image = None
|
| 123 |
-
step_counter = 0
|
| 124 |
-
for image in image_generator:
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
|
| 130 |
-
yield final_image, seed, gr.update(
|
| 131 |
|
| 132 |
css = '''
|
| 133 |
#gen_btn{height: 100%}
|
|
|
|
| 116 |
if randomize_seed:
|
| 117 |
seed = random.randint(0, MAX_SEED)
|
| 118 |
|
| 119 |
+
# image_generator = generate_image(input_image, prompt_mash, steps, seed, cfg_scale, lora_scale, progress)
|
| 120 |
+
|
| 121 |
+
generator = torch.Generator(device="cuda").manual_seed(seed)
|
| 122 |
+
final_image = pipe(
|
| 123 |
+
image=input_image,
|
| 124 |
+
prompt=prompt_mash,
|
| 125 |
+
num_inference_steps=steps,
|
| 126 |
+
guidance_scale=cfg_scale,
|
| 127 |
+
generator=generator,
|
| 128 |
+
joint_attention_kwargs={"scale": lora_scale},
|
| 129 |
+
)
|
| 130 |
|
| 131 |
+
# # Consume the generator to get the final image
|
| 132 |
+
# final_image = None
|
| 133 |
+
# step_counter = 0
|
| 134 |
+
# for image in image_generator:
|
| 135 |
+
# step_counter+=1
|
| 136 |
+
# final_image = image
|
| 137 |
+
# progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
|
| 138 |
+
# yield image, seed, gr.update(value=progress_bar, visible=True)
|
| 139 |
|
| 140 |
+
yield final_image, seed, gr.update(visible=True)
|
| 141 |
|
| 142 |
css = '''
|
| 143 |
#gen_btn{height: 100%}
|