patrickvonplaten commited on
Commit
4b92eb9
1 Parent(s): 30a6f1e
Files changed (3) hide show
  1. README.md +5 -6
  2. app.py +47 -0
  3. requirements.txt +4 -0
README.md CHANGED
@@ -1,13 +1,12 @@
1
  ---
2
- title: Vq Vs Stable Diffusion
3
- emoji: 👁
4
- colorFrom: red
5
- colorTo: red
6
  sdk: gradio
7
- sdk_version: 3.9
8
  app_file: app.py
9
  pinned: false
10
- license: mit
11
  ---
12
 
13
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: I Like Flan
3
+ emoji: 🍮
4
+ colorFrom: gray
5
+ colorTo: purple
6
  sdk: gradio
7
+ sdk_version: 3.6
8
  app_file: app.py
9
  pinned: false
 
10
  ---
11
 
12
  Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import gradio as gr
3
+ import torch
4
+ from diffusers import DiffusionPipeline
5
+
6
+ print(f"Is CUDA available: {torch.cuda.is_available()}")
7
+ print(f"CUDA device: {torch.cuda.get_device_name(torch.cuda.current_device())}")
8
+
9
+ if torch.cuda.is_available():
10
+ pipe_sd = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", torch_dtype=torch.float16, revision="fp16", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN"))
11
+ pipe_vq = DiffusionPipeline.from_pretrained("microsoft/vq-diffusion-ithq", torch_dtype=torch.float16, revision="fp16")
12
+ else:
13
+ pipe_sd = DiffusionPipeline.from_pretrained("runwayml/stable-diffusion-v1-5", use_auth_token=os.getenv("HUGGING_FACE_HUB_TOKEN"))
14
+ pipe_vq = DiffusionPipeline.from_pretrained("microsoft/vq-diffusion-ithq")
15
+
16
+ examples = [
17
+ ["An astronaut riding a horse."],
18
+ ["A teddy bear playing in the water."],
19
+ ["A simple wedding cake with lego bride and groom topper and cake pops."],
20
+ ["A realistic tree using a mixture of different colored pencils."],
21
+ ["Muscular Santa Claus."],
22
+ ["A man with a pineapple head."],
23
+ ["Pebble tower standing on the left on the sea beach."],
24
+ ]
25
+
26
+ title = "VQ Diffusion vs. Stable Diffusion 1-5"
27
+ description = "This demo compares [VQ-Diffusion-ITHQ](https://huggingface.co/microsoft/vq-diffusion-ithq) and [Stable-Diffusion-v1-5](https://huggingface.co/runwayml/stable-diffusion-v1-5) for text to image generation."
28
+
29
+
30
+ def inference(text):
31
+ output_sd = pipe_sd(text).images[0]
32
+ output_vq_diffusion = pipe_vq(text, truncation_rate=0.86).images[0]
33
+ return [output_vq_diffusion, output_sd]
34
+
35
+
36
+ io = gr.Interface(
37
+ inference,
38
+ gr.Textbox(lines=3),
39
+ outputs=[
40
+ gr.Image(type="pil", label="VQ-Diffusion"),
41
+ gr.Image(type="pil", label="Stable Diffusion"),
42
+ ],
43
+ title=title,
44
+ description=description,
45
+ examples=examples
46
+ )
47
+ io.launch()
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ --extra-index-url https://download.pytorch.org/whl/cu113
2
+ torch
3
+ transformers
4
+ diffusers[torch]