Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -6,14 +6,11 @@ from PIL import Image
|
|
6 |
from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import login
|
8 |
import os
|
9 |
-
from diffusers.models import AutoencoderKL
|
10 |
|
11 |
login(token=os.environ.get('HF_KEY'))
|
12 |
|
13 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
14 |
|
15 |
-
vae = AutoencoderKL.from_pretrained("stabilityai/sdxl-vae")
|
16 |
-
|
17 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", use_safetensors=True, vae=vae)
|
18 |
pipe = pipe.to(device)
|
19 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
@@ -25,7 +22,7 @@ refiner.unet = torch.compile(refiner.unet, mode="reduce-overhead", fullgraph=Tru
|
|
25 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
26 |
generator = torch.Generator(device=device).manual_seed(seed)
|
27 |
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, width=768, height=768, output_type="latent").images
|
28 |
-
image = refiner(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.'), gr.Textbox(label='What you Do Not want the AI to generate.'), gr.Slider(1, 15, 10), gr.Slider(25, maximum=50, value=25, step=1), gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)], outputs='image', title="Stable Diffusion XL .9 CPU", description="SDXL .9 CPU. <b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively.", article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
|
|
|
6 |
from diffusers import DiffusionPipeline
|
7 |
from huggingface_hub import login
|
8 |
import os
|
|
|
9 |
|
10 |
login(token=os.environ.get('HF_KEY'))
|
11 |
|
12 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
13 |
|
|
|
|
|
14 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", use_safetensors=True, vae=vae)
|
15 |
pipe = pipe.to(device)
|
16 |
pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
|
|
22 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
23 |
generator = torch.Generator(device=device).manual_seed(seed)
|
24 |
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator, width=768, height=768, output_type="latent").images
|
25 |
+
image = refiner(prompt=prompt, negative_prompt=negative_prompt, image=int_image).images[0]
|
26 |
return image
|
27 |
|
28 |
gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generate. 77 Token Limit.'), gr.Textbox(label='What you Do Not want the AI to generate.'), gr.Slider(1, 15, 10), gr.Slider(25, maximum=50, value=25, step=1), gr.Slider(minimum=1, step=1, maximum=999999999999999999, randomize=True)], outputs='image', title="Stable Diffusion XL .9 CPU", description="SDXL .9 CPU. <b>WARNING:</b> Extremely Slow. 65s/Iteration. Expect 25-50mins an image for 25-50 iterations respectively.", article = "Code Monkey: <a href=\"https://huggingface.co/Manjushri\">Manjushri</a>").launch(debug=True, max_threads=80)
|