multimodalart HF staff commited on
Commit
063e7c6
β€’
1 Parent(s): 2aacbba

Speed and UI updates

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -1,17 +1,21 @@
1
  from diffusers import StableDiffusionXLPipeline
2
- from diffusers.pipelines.stable_diffusion_xl import StableDiffusionXLPipelineOutput
3
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
4
  import torch
5
  from PIL import Image, ImageOps
6
  import gradio as gr
7
 
 
8
  pipe = StableDiffusionXLPipeline.from_pretrained(
9
  "stabilityai/stable-diffusion-xl-base-1.0",
 
10
  torch_dtype=torch.float16,
11
- variants="fp16",
12
- use_safetensor=True,
13
  )
14
  pipe.to("cuda")
 
 
15
 
16
  @torch.no_grad()
17
  def call(
@@ -320,13 +324,10 @@ with gr.Blocks(css=css) as app:
320
  '''
321
  <center>
322
  <h1>Upside Down Diffusion</h1>
323
- <p>Code by Alex Carlier, please follow them on <a href="https://twitter.com/alexcarliera">Twitter</a></p>
324
  <p>A space by <a href="https://twitter.com/angrypenguinPNG">AP</a> with contributions from <a href="https://twitter.com/multimodalart">MultimodalArt</a></p>
325
  </center>
326
  <hr>
327
- <p>
328
- 🌟 <strong>Create Perception Illusions with Stable Diffusion!</strong> 🌟
329
- </p>
330
  <p>
331
  Enter your first prompt to craft an image that will show when upright. Then, add a second prompt to reveal a mesmerizing surprise when you flip the image upside down! ✨
332
  </p>
@@ -339,8 +340,8 @@ with gr.Blocks(css=css) as app:
339
  has_flipped = gr.State(value=False)
340
  with gr.Row():
341
  with gr.Column():
342
- prompt1 = gr.Textbox(label="Prompt 1")
343
- prompt2 = gr.Textbox(label="Prompt 2")
344
  run_btn = gr.Button("Run")
345
 
346
  with gr.Column():
 
1
  from diffusers import StableDiffusionXLPipeline
2
+ from diffusers.pipelines.stable_diffusion_xl import StableDiffusionXLPipelineOutput, AutoencoderKL
3
  from typing import Any, Callable, Dict, List, Optional, Tuple, Union
4
  import torch
5
  from PIL import Image, ImageOps
6
  import gradio as gr
7
 
8
+ vae = AutoencoderKL.from_pretrained("madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16)
9
  pipe = StableDiffusionXLPipeline.from_pretrained(
10
  "stabilityai/stable-diffusion-xl-base-1.0",
11
+ vae=vae,
12
  torch_dtype=torch.float16,
13
+ variant="fp16",
14
+ use_safetensors=True,
15
  )
16
  pipe.to("cuda")
17
+ pipe.unet.to(memory_format=torch.channels_last)
18
+ pipe.unet = torch.compile(pipe.unet, mode="reduce-overhead", fullgraph=True)
19
 
20
  @torch.no_grad()
21
  def call(
 
324
  '''
325
  <center>
326
  <h1>Upside Down Diffusion</h1>
327
+ <p>Code by Alex Carlier, find their <a href="https://colab.research.google.com/drive/1rjDQOn11cTHAf3Oeq87Hfl_Vh41NbTl4?usp=sharing">Google Colab</a> here and please follow them on <a href="https://twitter.com/alexcarliera">Twitter</a></p>
328
  <p>A space by <a href="https://twitter.com/angrypenguinPNG">AP</a> with contributions from <a href="https://twitter.com/multimodalart">MultimodalArt</a></p>
329
  </center>
330
  <hr>
 
 
 
331
  <p>
332
  Enter your first prompt to craft an image that will show when upright. Then, add a second prompt to reveal a mesmerizing surprise when you flip the image upside down! ✨
333
  </p>
 
340
  has_flipped = gr.State(value=False)
341
  with gr.Row():
342
  with gr.Column():
343
+ prompt1 = gr.Textbox(label="Prompt 1", info="Prompt for the side up", placeholder="A sketch of a...")
344
+ prompt2 = gr.Textbox(label="Prompt 2", info="Prompt for the side down", placeholder="A sketch of a...")
345
  run_btn = gr.Button("Run")
346
 
347
  with gr.Column():