Update app.py
Browse files
app.py
CHANGED
@@ -14,25 +14,25 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
14 |
torch.cuda.max_memory_allocated(device=device)
|
15 |
|
16 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
|
|
14 |
torch.cuda.max_memory_allocated(device=device)
|
15 |
|
16 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
17 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
18 |
+
pipe = pipe.to(device)
|
19 |
+
pipe.enable_xformers_memory_efficient_attention()
|
20 |
+
torch.cuda.empty_cache()
|
21 |
+
generator = torch.Generator(device=device).manual_seed(seed)
|
22 |
+
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, ).images
|
23 |
+
torch.cuda.empty_cache()
|
24 |
+
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
25 |
+
pipe = pipe.to(device)
|
26 |
+
pipe.enable_xformers_memory_efficient_attention()
|
27 |
+
torch.cuda.empty_cache()
|
28 |
+
image = pipe(prompt=prompt, image=int_image).images[0]
|
29 |
+
return image
|
30 |
+
|
31 |
+
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'),
|
32 |
+
gr.Textbox(label='What you Do Not want the AI to generate.'),
|
33 |
+
gr.Slider(1, 15, 10), gr.Slider(25, maximum=50, value=25, step=1),
|
34 |
+
gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)],
|
35 |
+
outputs='image',
|
36 |
+
title="Stable Diffusion XL .9 CPU",
|
37 |
+
description="SDXL 0.9 GPU. <b>WARNING:</b> Capable of producing NSFW images.",
|
38 |
+
article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
|