Update app.py
Browse files
app.py
CHANGED
@@ -384,8 +384,8 @@ def run_lora(prompt, cfg_scale, steps, selected_indices, lora_scale_1, lora_scal
|
|
384 |
low_cpu_mem_usage=True,
|
385 |
adapter_name=lora_name
|
386 |
)
|
387 |
-
|
388 |
-
|
389 |
print("Loaded LoRAs:", lora_names)
|
390 |
print("Adapter weights:", lora_weights)
|
391 |
if image_input is not None:
|
@@ -398,21 +398,21 @@ def run_lora(prompt, cfg_scale, steps, selected_indices, lora_scale_1, lora_scal
|
|
398 |
if randomize_seed:
|
399 |
seed = random.randint(0, MAX_SEED)
|
400 |
|
401 |
-
|
402 |
-
|
403 |
final_image = generate_image_to_image(prompt_mash, steps, cfg_scale, width, height, seed)
|
404 |
yield final_image, seed, gr.update(visible=False)
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
|
417 |
run_lora.zerogpu = True
|
418 |
|
|
|
384 |
low_cpu_mem_usage=True,
|
385 |
adapter_name=lora_name
|
386 |
)
|
387 |
+
if image_input is not None: pipe_i2i = pipe_to_use
|
388 |
+
else: pipe = pipe_to_use
|
389 |
print("Loaded LoRAs:", lora_names)
|
390 |
print("Adapter weights:", lora_weights)
|
391 |
if image_input is not None:
|
|
|
398 |
if randomize_seed:
|
399 |
seed = random.randint(0, MAX_SEED)
|
400 |
|
401 |
+
# Generate image
|
402 |
+
if image_input is not None:
|
403 |
final_image = generate_image_to_image(prompt_mash, steps, cfg_scale, width, height, seed)
|
404 |
yield final_image, seed, gr.update(visible=False)
|
405 |
+
else:
|
406 |
+
image_generator = generate_image(prompt_mash, steps, seed, cfg_scale, width, height, progress)
|
407 |
+
# Consume the generator to get the final image
|
408 |
+
final_image = None
|
409 |
+
step_counter = 0
|
410 |
+
for image in image_generator:
|
411 |
+
step_counter += 1
|
412 |
+
final_image = image
|
413 |
+
progress_bar = f'<div class="progress-container"><div class="progress-bar" style="--current: {step_counter}; --total: {steps};"></div></div>'
|
414 |
+
yield image, seed, gr.update(value=progress_bar, visible=True)
|
415 |
+
yield final_image, seed, gr.update(value=progress_bar, visible=False)
|
416 |
|
417 |
run_lora.zerogpu = True
|
418 |
|