Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
ec573ee
1
Parent(s):
59b79ad
app.py
CHANGED
@@ -1,3 +1,4 @@
|
|
|
|
1 |
import os
|
2 |
import random
|
3 |
import gradio as gr
|
@@ -310,6 +311,8 @@ def generate_image(image_path, prompt, num_steps, guidance_scale, seed, num_imag
|
|
310 |
lora_prefix = Loras_dict[lora_name]
|
311 |
|
312 |
prompt = f"{lora_prefix} {prompt}"
|
|
|
|
|
313 |
|
314 |
|
315 |
print("Start inference...")
|
@@ -334,6 +337,9 @@ def generate_image(image_path, prompt, num_steps, guidance_scale, seed, num_imag
|
|
334 |
pipe.unfuse_lora()
|
335 |
pipe.unload_lora_weights()
|
336 |
|
|
|
|
|
|
|
337 |
return images
|
338 |
|
339 |
### Description
|
@@ -434,7 +440,7 @@ with gr.Blocks(css=css) as demo:
|
|
434 |
step=1,
|
435 |
value=0,
|
436 |
)
|
437 |
-
|
438 |
label="lora_scale",
|
439 |
minimum=0.0,
|
440 |
maximum=1.0,
|
@@ -454,7 +460,7 @@ with gr.Blocks(css=css) as demo:
|
|
454 |
api_name=False,
|
455 |
).then(
|
456 |
fn=generate_image,
|
457 |
-
inputs=[img_file, prompt, num_steps, guidance_scale, seed, num_images, ip_adapter_scale, kps_scale, canny_scale, lora_name],
|
458 |
outputs=[gallery]
|
459 |
)
|
460 |
|
|
|
1 |
+
import gc
|
2 |
import os
|
3 |
import random
|
4 |
import gradio as gr
|
|
|
311 |
lora_prefix = Loras_dict[lora_name]
|
312 |
|
313 |
prompt = f"{lora_prefix} {prompt}"
|
314 |
+
|
315 |
+
print("Using LoRA: ", lora_name)
|
316 |
|
317 |
|
318 |
print("Start inference...")
|
|
|
337 |
pipe.unfuse_lora()
|
338 |
pipe.unload_lora_weights()
|
339 |
|
340 |
+
gc.collect()
|
341 |
+
torch.cuda.empty_cache()
|
342 |
+
|
343 |
return images
|
344 |
|
345 |
### Description
|
|
|
440 |
step=1,
|
441 |
value=0,
|
442 |
)
|
443 |
+
lora_scale = gr.Slider(
|
444 |
label="lora_scale",
|
445 |
minimum=0.0,
|
446 |
maximum=1.0,
|
|
|
460 |
api_name=False,
|
461 |
).then(
|
462 |
fn=generate_image,
|
463 |
+
inputs=[img_file, prompt, num_steps, guidance_scale, seed, num_images, ip_adapter_scale, kps_scale, canny_scale, lora_name, lora_scale],
|
464 |
outputs=[gallery]
|
465 |
)
|
466 |
|