Spaces:
Runtime error
Runtime error
Commit
·
4d41f30
1
Parent(s):
7fc9487
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,11 +7,11 @@ pipe = SemanticEditPipeline.from_pretrained(
|
|
| 7 |
"runwayml/stable-diffusion-v1-5",
|
| 8 |
).to(device)
|
| 9 |
|
| 10 |
-
def infer(prompt):
|
| 11 |
|
| 12 |
gen = torch.Generator(device=device)
|
| 13 |
|
| 14 |
-
gen.manual_seed(
|
| 15 |
out = pipe(prompt=prompt, generator=gen, num_images_per_prompt=1, guidance_scale=7)
|
| 16 |
images = out.images[0]
|
| 17 |
out_edit = pipe(prompt=prompt, generator=gen, num_images_per_prompt=1, guidance_scale=7,
|
|
@@ -159,6 +159,7 @@ block = gr.Blocks(css=css)
|
|
| 159 |
examples = [
|
| 160 |
[
|
| 161 |
'A photo of the face of a firefighter',
|
|
|
|
| 162 |
]
|
| 163 |
|
| 164 |
]
|
|
@@ -251,6 +252,7 @@ with block:
|
|
| 251 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 252 |
).style(height="auto")
|
| 253 |
|
|
|
|
| 254 |
# with gr.Group(elem_id="container-advanced-btns"):
|
| 255 |
# #advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
| 256 |
# with gr.Group(elem_id="share-btn-container"):
|
|
@@ -258,20 +260,20 @@ with block:
|
|
| 258 |
# loading_icon = gr.HTML(loading_icon_html)
|
| 259 |
# share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 260 |
|
| 261 |
-
|
| 262 |
-
|
| 263 |
-
|
| 264 |
-
|
| 265 |
-
|
| 266 |
-
|
| 267 |
-
|
| 268 |
|
| 269 |
-
ex = gr.Examples(examples=examples, fn=infer, inputs=[text], outputs=[gallery], cache_examples=True)
|
| 270 |
ex.dataset.headers = [""]
|
| 271 |
|
| 272 |
|
| 273 |
-
text.submit(infer, inputs=[text], outputs=[gallery])
|
| 274 |
-
btn.click(infer, inputs=[text], outputs=[gallery])
|
| 275 |
|
| 276 |
|
| 277 |
|
|
|
|
| 7 |
"runwayml/stable-diffusion-v1-5",
|
| 8 |
).to(device)
|
| 9 |
|
| 10 |
+
def infer(prompt,seed):
|
| 11 |
|
| 12 |
gen = torch.Generator(device=device)
|
| 13 |
|
| 14 |
+
gen.manual_seed(seed)
|
| 15 |
out = pipe(prompt=prompt, generator=gen, num_images_per_prompt=1, guidance_scale=7)
|
| 16 |
images = out.images[0]
|
| 17 |
out_edit = pipe(prompt=prompt, generator=gen, num_images_per_prompt=1, guidance_scale=7,
|
|
|
|
| 159 |
examples = [
|
| 160 |
[
|
| 161 |
'A photo of the face of a firefighter',
|
| 162 |
+
21
|
| 163 |
]
|
| 164 |
|
| 165 |
]
|
|
|
|
| 252 |
label="Generated images", show_label=False, elem_id="gallery"
|
| 253 |
).style(height="auto")
|
| 254 |
|
| 255 |
+
with gr.Accordion("Advanced settings", open=False):
|
| 256 |
# with gr.Group(elem_id="container-advanced-btns"):
|
| 257 |
# #advanced_button = gr.Button("Advanced options", elem_id="advanced-btn")
|
| 258 |
# with gr.Group(elem_id="share-btn-container"):
|
|
|
|
| 260 |
# loading_icon = gr.HTML(loading_icon_html)
|
| 261 |
# share_button = gr.Button("Share to community", elem_id="share-btn")
|
| 262 |
|
| 263 |
+
seed = gr.Slider(
|
| 264 |
+
label="Seed",
|
| 265 |
+
minimum=0,
|
| 266 |
+
maximum=2147483647,
|
| 267 |
+
step=1,
|
| 268 |
+
randomize=True,
|
| 269 |
+
)
|
| 270 |
|
| 271 |
+
ex = gr.Examples(examples=examples, fn=infer, inputs=[text, seed], outputs=[gallery], cache_examples=True)
|
| 272 |
ex.dataset.headers = [""]
|
| 273 |
|
| 274 |
|
| 275 |
+
text.submit(infer, inputs=[text,seed], outputs=[gallery])
|
| 276 |
+
btn.click(infer, inputs=[text,seed], outputs=[gallery])
|
| 277 |
|
| 278 |
|
| 279 |
|