Spaces:
Running
on
Zero
Running
on
Zero
Update app.py
Browse files
app.py
CHANGED
@@ -18,20 +18,27 @@ pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow
|
|
18 |
|
19 |
|
20 |
@spaces.GPU()
|
21 |
-
def generate(prompt, negative_prompt, width=
|
|
|
|
|
|
|
22 |
pipe.to("cuda")
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
|
|
|
|
|
|
|
|
35 |
|
36 |
iface = gr.Interface(
|
37 |
fn=generate,
|
@@ -42,7 +49,8 @@ iface = gr.Interface(
|
|
42 |
gr.Textbox(label="Negative prompt", value = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"),
|
43 |
gr.Slider(label="Width", minimum=480, maximum=1280, step=16, value=1024),
|
44 |
gr.Slider(label="Height", minimum=480, maximum=1280, step=16, value=1024),
|
45 |
-
gr.Slider(minimum=1, maximum=80, step=1, label="Inference Steps", value=
|
|
|
46 |
],
|
47 |
outputs=gr.Image(label="output"),
|
48 |
)
|
|
|
18 |
|
19 |
|
20 |
@spaces.GPU()
|
21 |
+
def generate(prompt, negative_prompt, width=1024, height=1024, num_inference_steps=30, lora_id=None, progress=gr.Progress(track_tqdm=True)):
|
22 |
+
if lora_id and lora_id.strip() != "":
|
23 |
+
pipe.unload_lora_weights()
|
24 |
+
pipe.load_lora_weights(lora_id.strip())
|
25 |
pipe.to("cuda")
|
26 |
+
try:
|
27 |
+
output = pipe(
|
28 |
+
prompt=prompt,
|
29 |
+
negative_prompt=negative_prompt,
|
30 |
+
height=height,
|
31 |
+
width=width,
|
32 |
+
num_frames=1,
|
33 |
+
num_inference_steps=num_inference_steps,
|
34 |
+
guidance_scale=5.0,
|
35 |
+
)
|
36 |
+
image = output.frames[0][0]
|
37 |
+
image = (image * 255).astype(np.uint8)
|
38 |
+
return Image.fromarray(image)
|
39 |
+
finally:
|
40 |
+
if lora_id and lora_id.strip() != "":
|
41 |
+
pipe.unload_lora_weights()
|
42 |
|
43 |
iface = gr.Interface(
|
44 |
fn=generate,
|
|
|
49 |
gr.Textbox(label="Negative prompt", value = "Bright tones, overexposed, static, blurred details, subtitles, style, works, paintings, images, static, overall gray, worst quality, low quality, JPEG compression residue, ugly, incomplete, extra fingers, poorly drawn hands, poorly drawn faces, deformed, disfigured, misshapen limbs, fused fingers, still picture, messy background, three legs, many people in the background, walking backwards"),
|
50 |
gr.Slider(label="Width", minimum=480, maximum=1280, step=16, value=1024),
|
51 |
gr.Slider(label="Height", minimum=480, maximum=1280, step=16, value=1024),
|
52 |
+
gr.Slider(minimum=1, maximum=80, step=1, label="Inference Steps", value=30),
|
53 |
+
gr.Textbox(label="LoRA ID"),
|
54 |
],
|
55 |
outputs=gr.Image(label="output"),
|
56 |
)
|