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