Spaces:
Runtime error
Runtime error
clementchadebec
commited on
Commit
•
dc10896
1
Parent(s):
137df64
Update app.py
Browse files
app.py
CHANGED
@@ -64,7 +64,7 @@ NUM_INFERENCE_STEPS = 4
|
|
64 |
|
65 |
|
66 |
@spaces.GPU
|
67 |
-
def infer(prompt, seed, randomize_seed):
|
68 |
if randomize_seed:
|
69 |
seed = random.randint(0, MAX_SEED)
|
70 |
|
@@ -72,9 +72,10 @@ def infer(prompt, seed, randomize_seed):
|
|
72 |
|
73 |
image = pipe(
|
74 |
prompt=prompt,
|
75 |
-
guidance_scale=
|
76 |
-
num_inference_steps=
|
77 |
generator=generator,
|
|
|
78 |
).images[0]
|
79 |
|
80 |
return image
|
@@ -82,7 +83,7 @@ def infer(prompt, seed, randomize_seed):
|
|
82 |
|
83 |
examples = [
|
84 |
"The image showcases a freshly baked bread, possibly focaccia, with rosemary sprigs and red pepper flakes sprinkled on top. It's sliced and placed on a wire cooling rack, with a bowl of mixed peppercorns beside it.",
|
85 |
-
'a 3D render of a wizard raccoon holding a sign saying "
|
86 |
"A panda reading a book in a lush forest.",
|
87 |
"A raccoon trapped inside a glass jar full of colorful candies, the background is steamy with vivid colors",
|
88 |
"Pirate ship sailing on a sea with the milky way galaxy in the sky and purple glow lights",
|
@@ -137,6 +138,14 @@ with gr.Blocks(css=css) as demo:
|
|
137 |
result = gr.Image(label="Result", show_label=False)
|
138 |
|
139 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
seed = gr.Slider(
|
141 |
label="Seed",
|
142 |
minimum=0,
|
@@ -147,6 +156,24 @@ with gr.Blocks(css=css) as demo:
|
|
147 |
|
148 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
149 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
150 |
examples = gr.Examples(examples=examples, inputs=[prompt], cache_examples=False)
|
151 |
|
152 |
gr.Markdown("**Disclaimer:**")
|
@@ -156,7 +183,7 @@ with gr.Blocks(css=css) as demo:
|
|
156 |
gr.on(
|
157 |
[run_button.click, seed.change, randomize_seed.change, prompt.submit],
|
158 |
fn=infer,
|
159 |
-
inputs=[prompt, seed, randomize_seed],
|
160 |
outputs=[result],
|
161 |
show_progress="minimal",
|
162 |
show_api=False,
|
|
|
64 |
|
65 |
|
66 |
@spaces.GPU
|
67 |
+
def infer(prompt, seed, randomize_seed, guidance_scale, num_inference_steps, negative_prompt):
|
68 |
if randomize_seed:
|
69 |
seed = random.randint(0, MAX_SEED)
|
70 |
|
|
|
72 |
|
73 |
image = pipe(
|
74 |
prompt=prompt,
|
75 |
+
guidance_scale=guidance_scale,
|
76 |
+
num_inference_steps=num_inference_steps,
|
77 |
generator=generator,
|
78 |
+
negative_prompt=negative_prompt
|
79 |
).images[0]
|
80 |
|
81 |
return image
|
|
|
83 |
|
84 |
examples = [
|
85 |
"The image showcases a freshly baked bread, possibly focaccia, with rosemary sprigs and red pepper flakes sprinkled on top. It's sliced and placed on a wire cooling rack, with a bowl of mixed peppercorns beside it.",
|
86 |
+
'a 3D render of a wizard raccoon holding a sign saying "I was generated in 8 steps" with a magic wand.',
|
87 |
"A panda reading a book in a lush forest.",
|
88 |
"A raccoon trapped inside a glass jar full of colorful candies, the background is steamy with vivid colors",
|
89 |
"Pirate ship sailing on a sea with the milky way galaxy in the sky and purple glow lights",
|
|
|
138 |
result = gr.Image(label="Result", show_label=False)
|
139 |
|
140 |
with gr.Accordion("Advanced Settings", open=False):
|
141 |
+
|
142 |
+
negative_prompt = gr.Text(
|
143 |
+
label="Negative prompt",
|
144 |
+
max_lines=1,
|
145 |
+
placeholder="Enter a negative prompt",
|
146 |
+
value="deformed, distorted, disfigured, poorly drawn, bad anatomy, wrong anatomy, extra limb, missing limb, floating limbs, mutated hands and fingers, disconnected limbs, mutation, mutated, ugly, disgusting, blurry, amputation, NSFW, bad text"
|
147 |
+
)
|
148 |
+
|
149 |
seed = gr.Slider(
|
150 |
label="Seed",
|
151 |
minimum=0,
|
|
|
156 |
|
157 |
randomize_seed = gr.Checkbox(label="Randomize seed", value=True)
|
158 |
|
159 |
+
with gr.Row():
|
160 |
+
|
161 |
+
guidance_scale = gr.Slider(
|
162 |
+
label="Guidance scale",
|
163 |
+
minimum=0.0,
|
164 |
+
maximum=3.0,
|
165 |
+
step=0.1,
|
166 |
+
value=2.0,
|
167 |
+
)
|
168 |
+
|
169 |
+
num_inference_steps = gr.Slider(
|
170 |
+
label="Number of inference steps",
|
171 |
+
minimum=4,
|
172 |
+
maximum=8,
|
173 |
+
step=1,
|
174 |
+
value=8,
|
175 |
+
)
|
176 |
+
|
177 |
examples = gr.Examples(examples=examples, inputs=[prompt], cache_examples=False)
|
178 |
|
179 |
gr.Markdown("**Disclaimer:**")
|
|
|
183 |
gr.on(
|
184 |
[run_button.click, seed.change, randomize_seed.change, prompt.submit],
|
185 |
fn=infer,
|
186 |
+
inputs=[prompt, seed, randomize_seed, guidance_scale, num_inference_steps, negative_prompt],
|
187 |
outputs=[result],
|
188 |
show_progress="minimal",
|
189 |
show_api=False,
|