Manjushri commited on
Commit
33eab73
1 Parent(s): a24f4fd

Update app.py

Browse files

Added pipe.enable_xformers_memory_efficient_attention()
upscaler.enable_xformers_memory_efficient_attention()
Set grRadio Value to No.

Files changed (1) hide show
  1. app.py +5 -2
app.py CHANGED
@@ -8,9 +8,12 @@ from diffusers import DiffusionPipeline, StableDiffusionLatentUpscalePipeline
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
 
10
  pipe = DiffusionPipeline.from_pretrained("dreamlike-art/dreamlike-photoreal-2.0", torch_dtype=torch.float16, safety_checker=None)
 
 
11
  upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16, safety_checker=None)
12
  upscaler = upscaler.to(device)
13
- pipe = pipe.to(device)
 
14
 
15
  def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
16
  generator = torch.Generator(device=device).manual_seed(seed)
@@ -28,7 +31,7 @@ gr.Interface(fn=genie, inputs=[gr.Textbox(label='What you want the AI to generat
28
  gr.Slider(1, maximum=15, value=10, step=.25),
29
  gr.Slider(25, maximum=100, value=50, step=25),
30
  gr.Slider(minimum=1, step=1, maximum=9999999999999999, randomize=True),
31
- gr.Radio(["Yes", "No"], label='Upscale?'),
32
  ],
33
  outputs=gr.Image(label='Generated Image'),
34
  title="PhotoReal V2 with SD x2 Upscaler - GPU",
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
 
10
  pipe = DiffusionPipeline.from_pretrained("dreamlike-art/dreamlike-photoreal-2.0", torch_dtype=torch.float16, safety_checker=None)
11
+ pipe = pipe.to(device)
12
+ pipe.enable_xformers_memory_efficient_attention()
13
  upscaler = StableDiffusionLatentUpscalePipeline.from_pretrained("stabilityai/sd-x2-latent-upscaler", torch_dtype=torch.float16, safety_checker=None)
14
  upscaler = upscaler.to(device)
15
+ upscaler.enable_xformers_memory_efficient_attention()
16
+
17
 
18
  def genie (Prompt, negative_prompt, height, width, scale, steps, seed, upscale):
19
  generator = torch.Generator(device=device).manual_seed(seed)
 
31
  gr.Slider(1, maximum=15, value=10, step=.25),
32
  gr.Slider(25, maximum=100, value=50, step=25),
33
  gr.Slider(minimum=1, step=1, maximum=9999999999999999, randomize=True),
34
+ gr.Radio(["Yes", "No"], label='Upscale?', value='No'),
35
  ],
36
  outputs=gr.Image(label='Generated Image'),
37
  title="PhotoReal V2 with SD x2 Upscaler - GPU",