Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
@@ -7,10 +7,21 @@ from diffusers import StableDiffusionPipeline
|
|
7 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
8 |
"nroggendorff/zelda-diffusion"
|
9 |
).to("cuda")
|
|
|
10 |
|
11 |
@spaces.GPU
|
12 |
-
def generate(prompt, negative_prompt, width, height, sample_steps):
|
13 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
with gr.Blocks() as interface:
|
16 |
with gr.Column():
|
@@ -27,10 +38,11 @@ with gr.Blocks() as interface:
|
|
27 |
with gr.Column():
|
28 |
width = gr.Slider(label="Width", info="The width in pixels of the generated image.", value=512, minimum=128, maximum=4096, step=64, interactive=True)
|
29 |
height = gr.Slider(label="Height", info="The height in pixels of the generated image.", value=512, minimum=128, maximum=4096, step=64, interactive=True)
|
|
|
30 |
with gr.Column():
|
31 |
sampling_steps = gr.Slider(label="Sampling Steps", info="The number of denoising steps.", value=20, minimum=4, maximum=50, step=1, interactive=True)
|
32 |
|
33 |
-
generate_button.click(fn=generate, inputs=[prompt, negative_prompt, width, height, sampling_steps], outputs=[output])
|
34 |
|
35 |
if __name__ == "__main__":
|
36 |
interface.launch()
|
|
|
7 |
pipeline = StableDiffusionPipeline.from_pretrained(
|
8 |
"nroggendorff/zelda-diffusion"
|
9 |
).to("cuda")
|
10 |
+
img2img = StableDiffusionImg2ImgPipeline(**text2img.components)
|
11 |
|
12 |
@spaces.GPU
|
13 |
+
def generate(prompt, negative_prompt, width, height, sample_steps, hrf):
|
14 |
+
image = pipeline(prompt=prompt, negative_prompt=negative_prompt, width=width, height=height, num_inference_steps=sample_steps).images[0]
|
15 |
+
if hrf:
|
16 |
+
return img2img(
|
17 |
+
prompt=prompt,
|
18 |
+
image=image,
|
19 |
+
strength=0.75,
|
20 |
+
width=width * 2,
|
21 |
+
height=height * 2
|
22 |
+
).images[0]
|
23 |
+
else:
|
24 |
+
return image
|
25 |
|
26 |
with gr.Blocks() as interface:
|
27 |
with gr.Column():
|
|
|
38 |
with gr.Column():
|
39 |
width = gr.Slider(label="Width", info="The width in pixels of the generated image.", value=512, minimum=128, maximum=4096, step=64, interactive=True)
|
40 |
height = gr.Slider(label="Height", info="The height in pixels of the generated image.", value=512, minimum=128, maximum=4096, step=64, interactive=True)
|
41 |
+
hrf = gr.Checkbox(label="High-Res Fix", info="Run through img2img.", value=False)
|
42 |
with gr.Column():
|
43 |
sampling_steps = gr.Slider(label="Sampling Steps", info="The number of denoising steps.", value=20, minimum=4, maximum=50, step=1, interactive=True)
|
44 |
|
45 |
+
generate_button.click(fn=generate, inputs=[prompt, negative_prompt, width, height, sampling_steps, hrf], outputs=[output])
|
46 |
|
47 |
if __name__ == "__main__":
|
48 |
interface.launch()
|