Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -14,25 +14,23 @@ device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
14 |
torch.cuda.max_memory_allocated(device=device)
|
15 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
16 |
pipe = pipe.to(device)
|
17 |
-
#pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
|
18 |
pipe.enable_xformers_memory_efficient_attention()
|
19 |
torch.cuda.empty_cache()
|
20 |
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
23 |
torch.cuda.empty_cache()
|
24 |
generator = torch.Generator(device=device).manual_seed(seed)
|
25 |
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
|
26 |
-
return int_image
|
27 |
-
|
28 |
-
def refiner(int_image):
|
29 |
-
torch.cuda.empty_cache()
|
30 |
-
refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
31 |
-
refiner = refiner.to(device)
|
32 |
-
refiner.enable_xformers_memory_efficient_attention()
|
33 |
-
torch.cuda.empty_cache()
|
34 |
image = refiner(prompt=prompt, image=int_image).images[0]
|
35 |
-
return image
|
|
|
|
|
36 |
|
37 |
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)
|
38 |
gr.Interface(fn=refiner, inputs='image', outputs='image').launch(debug=True)
|
|
|
14 |
torch.cuda.max_memory_allocated(device=device)
|
15 |
pipe = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-base-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
16 |
pipe = pipe.to(device)
|
|
|
17 |
pipe.enable_xformers_memory_efficient_attention()
|
18 |
torch.cuda.empty_cache()
|
19 |
|
20 |
|
21 |
+
refiner = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
|
22 |
+
refiner = refiner.to(device)
|
23 |
+
refiner.enable_xformers_memory_efficient_attention()
|
24 |
+
torch.cuda.empty_cache()
|
25 |
+
|
26 |
def genie (prompt, negative_prompt, scale, steps, seed):
|
27 |
torch.cuda.empty_cache()
|
28 |
generator = torch.Generator(device=device).manual_seed(seed)
|
29 |
int_image = pipe(prompt, negative_prompt=negative_prompt, num_inference_steps=steps, guidance_scale=scale, num_images_per_prompt=1, generator=generator).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
image = refiner(prompt=prompt, image=int_image).images[0]
|
31 |
+
return image
|
32 |
+
|
33 |
+
|
34 |
|
35 |
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)
|
36 |
gr.Interface(fn=refiner, inputs='image', outputs='image').launch(debug=True)
|