Update app.py
Browse filesAdding Embedded Prompts
app.py
CHANGED
@@ -33,16 +33,16 @@ else:
|
|
33 |
refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True)
|
34 |
refiner = refiner.to(device)
|
35 |
|
36 |
-
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaling):
|
37 |
generator = torch.Generator(device=device).manual_seed(seed)
|
38 |
-
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, height=height, width=width, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
|
39 |
if upscaling == 'Yes':
|
40 |
-
image = refiner(prompt=prompt, image=int_image).images[0]
|
41 |
upscaled = upscaler(prompt=prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=5, guidance_scale=0).images[0]
|
42 |
torch.cuda.empty_cache()
|
43 |
return (image, upscaled)
|
44 |
else:
|
45 |
-
image = refiner(prompt=prompt, negative_prompt=negative_prompt, image=int_image).images[0]
|
46 |
torch.cuda.empty_cache()
|
47 |
return (image, image)
|
48 |
|
@@ -53,7 +53,9 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
|
|
53 |
gr.Slider(1, 15, 10, step=.25, label='Guidance Scale: How Closely the AI follows the Prompt'),
|
54 |
gr.Slider(25, maximum=100, value=50, step=25, label='Number of Iterations'),
|
55 |
gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True, label='Seed'),
|
56 |
-
gr.Radio(['Yes', 'No'], label='Upscale?')
|
|
|
|
|
57 |
outputs=['image', 'image'],
|
58 |
title="Stable Diffusion XL 1.0 GPU",
|
59 |
description="SDXL 1.0 GPU. <br><br><b>WARNING: Capable of producing NSFW (Softcore) images.</b>",
|
|
|
33 |
refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", use_safetensors=True)
|
34 |
refiner = refiner.to(device)
|
35 |
|
36 |
+
def genie (prompt, negative_prompt, height, width, scale, steps, seed, upscaling, prompt_2, negative_prompt_2):
|
37 |
generator = torch.Generator(device=device).manual_seed(seed)
|
38 |
+
int_image = pipe(prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, num_inference_steps=steps, height=height, width=width, guidance_scale=scale, num_images_per_prompt=1, generator=generator, output_type="latent").images
|
39 |
if upscaling == 'Yes':
|
40 |
+
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image).images[0]
|
41 |
upscaled = upscaler(prompt=prompt, negative_prompt=negative_prompt, image=image, num_inference_steps=5, guidance_scale=0).images[0]
|
42 |
torch.cuda.empty_cache()
|
43 |
return (image, upscaled)
|
44 |
else:
|
45 |
+
image = refiner(prompt=prompt, prompt_2=prompt_2, negative_prompt=negative_prompt, negative_prompt_2=negative_prompt_2, image=int_image).images[0]
|
46 |
torch.cuda.empty_cache()
|
47 |
return (image, image)
|
48 |
|
|
|
53 |
gr.Slider(1, 15, 10, step=.25, label='Guidance Scale: How Closely the AI follows the Prompt'),
|
54 |
gr.Slider(25, maximum=100, value=50, step=25, label='Number of Iterations'),
|
55 |
gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True, label='Seed'),
|
56 |
+
gr.Radio(['Yes', 'No'], label='Upscale?'),
|
57 |
+
gr.Textbox(label='Embedded Prompt'),
|
58 |
+
gr.Textbox(label='Embedded Negative Prompt')],
|
59 |
outputs=['image', 'image'],
|
60 |
title="Stable Diffusion XL 1.0 GPU",
|
61 |
description="SDXL 1.0 GPU. <br><br><b>WARNING: Capable of producing NSFW (Softcore) images.</b>",
|