Spaces:
Running
on
Zero
Running
on
Zero
gokaygokay
commited on
Commit
•
dff35d4
1
Parent(s):
c259892
Update app.py
Browse files
app.py
CHANGED
@@ -33,17 +33,22 @@ pipe = pipe.to("cuda")
|
|
33 |
pipe.enable_model_cpu_offload()
|
34 |
|
35 |
@spaces.GPU
|
36 |
-
def generate_image(prompt, height, width, num_inference_steps, guidance_scale):
|
37 |
-
|
|
|
|
|
|
|
|
|
38 |
image = pipe(
|
39 |
prompt=prompt,
|
|
|
40 |
height=height,
|
41 |
width=width,
|
42 |
num_inference_steps=num_inference_steps,
|
43 |
guidance_scale=guidance_scale,
|
44 |
-
num_images_per_prompt=
|
45 |
generator=torch.Generator(pipe.device).manual_seed(seed)
|
46 |
-
).images
|
47 |
return image, seed
|
48 |
|
49 |
description = """
|
@@ -61,14 +66,18 @@ iface = gr.Interface(
|
|
61 |
fn=generate_image,
|
62 |
inputs=[
|
63 |
gr.Textbox(label="Prompt"),
|
64 |
-
gr.
|
65 |
-
gr.Slider(512,
|
|
|
66 |
gr.Slider(20, 50, 20, step=1, label="Number of Inference Steps"),
|
67 |
gr.Slider(1, 20, 5, step=0.5, label="Guidance Scale"),
|
|
|
|
|
|
|
68 |
],
|
69 |
outputs=[
|
70 |
-
gr.
|
71 |
-
gr.Number(label="Seed")
|
72 |
],
|
73 |
title="Kolors",
|
74 |
description=description,
|
|
|
33 |
pipe.enable_model_cpu_offload()
|
34 |
|
35 |
@spaces.GPU
|
36 |
+
def generate_image(prompt, negative_prompt, height, width, num_inference_steps, guidance_scale, num_images_per_prompt, use_random_seed, seed):
|
37 |
+
if use_random_seed:
|
38 |
+
seed = random.randint(0, 2**32 - 1)
|
39 |
+
else:
|
40 |
+
seed = int(seed) # Ensure seed is an integer
|
41 |
+
|
42 |
image = pipe(
|
43 |
prompt=prompt,
|
44 |
+
negative_prompt=negative_prompt,
|
45 |
height=height,
|
46 |
width=width,
|
47 |
num_inference_steps=num_inference_steps,
|
48 |
guidance_scale=guidance_scale,
|
49 |
+
num_images_per_prompt=num_images_per_prompt,
|
50 |
generator=torch.Generator(pipe.device).manual_seed(seed)
|
51 |
+
).images
|
52 |
return image, seed
|
53 |
|
54 |
description = """
|
|
|
66 |
fn=generate_image,
|
67 |
inputs=[
|
68 |
gr.Textbox(label="Prompt"),
|
69 |
+
gr.Textbox(label="Negative Prompt"),
|
70 |
+
gr.Slider(512, 2048, 1024, step=64, label="Height"),
|
71 |
+
gr.Slider(512, 2048, 1024, step=64, label="Width"),
|
72 |
gr.Slider(20, 50, 20, step=1, label="Number of Inference Steps"),
|
73 |
gr.Slider(1, 20, 5, step=0.5, label="Guidance Scale"),
|
74 |
+
gr.Slider(1, 4, 1, step=1, label="Number of images per prompt"),
|
75 |
+
gr.Checkbox(label="Use Random Seed", value=True),
|
76 |
+
gr.Number(label="Seed", value=0, precision=0),
|
77 |
],
|
78 |
outputs=[
|
79 |
+
gr.Gallery(label="Result", elem_id="gallery", show_label=False),
|
80 |
+
gr.Number(label="Seed Used")
|
81 |
],
|
82 |
title="Kolors",
|
83 |
description=description,
|