Spaces:
Running
on
T4
Running
on
T4
Update app.py
Browse filesAdded Negative Prompt and Upscaler option
app.py
CHANGED
|
@@ -11,18 +11,22 @@ upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-
|
|
| 11 |
upscaler = upscaler.to(device)
|
| 12 |
pipe = pipe.to(device)
|
| 13 |
|
| 14 |
-
def genie (Prompt, scale, steps, Seed):
|
| 15 |
generator = torch.Generator(device=device).manual_seed(Seed)
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
|
|
|
|
|
|
| 20 |
|
| 21 |
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|
|
|
|
| 22 |
gr.Slider(1, maximum=15, value=10, step=.25, label='Prompt Guidance Scale:', interactive=True),
|
| 23 |
gr.Slider(1, maximum=100, value=50, step=1, label='Number of Iterations: 50 is typically fine.'),
|
| 24 |
gr.Slider(minimum=1, step=10, maximum=999999999999999999, randomize=True, interactive=True)],
|
| 25 |
-
|
|
|
|
| 26 |
title="PhotoReal V2 with SD x2 Upscaler - GPU",
|
| 27 |
description="<br><br><b/>Warning: This Demo is capable of producing NSFW content.",
|
| 28 |
article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=True)
|
|
|
|
| 11 |
upscaler = upscaler.to(device)
|
| 12 |
pipe = pipe.to(device)
|
| 13 |
|
| 14 |
+
def genie (Prompt, negative_prompt, scale, steps, Seed, upscale):
|
| 15 |
generator = torch.Generator(device=device).manual_seed(Seed)
|
| 16 |
+
if upscale == "Yes":
|
| 17 |
+
low_res_latents = pipe(Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, generator=generator, output_type="latent").images
|
| 18 |
+
image = upscaler(prompt='', image=low_res_latents, num_inference_steps=5, guidance_scale=0, generator=generator).images[0]
|
| 19 |
+
else:
|
| 20 |
+
image = pipe(Prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, generator=generator).images[0]
|
| 21 |
+
return image
|
| 22 |
|
| 23 |
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|
| 24 |
+
gr.Textbox(label='What you Do Not want the AI to generate. 77 Token Limit'),
|
| 25 |
gr.Slider(1, maximum=15, value=10, step=.25, label='Prompt Guidance Scale:', interactive=True),
|
| 26 |
gr.Slider(1, maximum=100, value=50, step=1, label='Number of Iterations: 50 is typically fine.'),
|
| 27 |
gr.Slider(minimum=1, step=10, maximum=999999999999999999, randomize=True, interactive=True)],
|
| 28 |
+
gr.Radio(["Yes", "No"], label='Upscale?')],
|
| 29 |
+
outputs=gr.Image(label='Generated Image'),
|
| 30 |
title="PhotoReal V2 with SD x2 Upscaler - GPU",
|
| 31 |
description="<br><br><b/>Warning: This Demo is capable of producing NSFW content.",
|
| 32 |
article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=True)
|