Text-to-Image
Diffusers
Safetensors
Pixart-α
Lawrence-cj commited on
Commit
55cbfcf
1 Parent(s): 5803b35

Upload README.md

Browse files
Files changed (1) hide show
  1. README.md +151 -1
README.md CHANGED
@@ -1,3 +1,153 @@
1
  ---
2
- license: creativeml-openrail-m
 
 
 
3
  ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  ---
2
+ license: openrail++
3
+ tags:
4
+ - text-to-image
5
+ - Pixart-α
6
  ---
7
+
8
+ <p align="center">
9
+ <img src="asset/logo.png" height=120>
10
+ </p>
11
+
12
+ <div style="display:flex;justify-content: center">
13
+ <a href="https://huggingface.co/spaces/PixArt-alpha/PixArt-alpha"><img src="https://img.shields.io/static/v1?label=Demo&message=Huggingface&color=yellow"></a> &ensp;
14
+ <a href="https://pixart-alpha.github.io/"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Github&color=blue&logo=github-pages"></a> &ensp;
15
+ <a href="https://arxiv.org/abs/2310.00426"><img src="https://img.shields.io/static/v1?label=Paper&message=Arxiv&color=red&logo=arxiv"></a> &ensp;
16
+ <a href="https://colab.research.google.com/drive/1jZ5UZXk7tcpTfVwnX33dDuefNMcnW9ME?usp=sharing"><img src="https://img.shields.io/static/v1?label=Free%20Trial&message=Google%20Colab&logo=google&color=orange"></a> &ensp;
17
+ <a href="https://github.com/orgs/PixArt-alpha/discussions"><img src="https://img.shields.io/static/v1?label=Discussion&message=Github&color=green&logo=github"></a> &ensp;
18
+ </div>
19
+
20
+ # 🐱 Pixart-α Model Card
21
+ ![row01](asset/images/teaser.png)
22
+
23
+ ## Model
24
+ ![pipeline](asset/images/model.png)
25
+
26
+ [Pixart-α](https://arxiv.org/abs/2310.00426) consists of pure transformer blocks for latent diffusion:
27
+ It can directly generate 1024px images from text prompts within a single sampling process.
28
+
29
+ Source code is available at https://github.com/PixArt-alpha/PixArt-alpha.
30
+
31
+ ### Model Description
32
+
33
+ - **Developed by:** Pixart-α
34
+ - **Model type:** Diffusion-Transformer-based text-to-image generative model
35
+ - **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
36
+ - **Model Description:** This is a model that can be used to generate and modify images based on text prompts.
37
+ It is a [Transformer Latent Diffusion Model](https://arxiv.org/abs/2310.00426) that uses one fixed, pretrained text encoders ([T5](
38
+ https://huggingface.co/DeepFloyd/t5-v1_1-xxl))
39
+ and one latent feature encoder ([VAE](https://arxiv.org/abs/2112.10752)).
40
+ - **Resources for more information:** Check out our [GitHub Repository](https://github.com/PixArt-alpha/PixArt-alpha) and the [Pixart-α report on arXiv](https://arxiv.org/abs/2310.00426).
41
+
42
+ ### Model Sources
43
+
44
+ For research purposes, we recommend our `generative-models` Github repository (https://github.com/PixArt-alpha/PixArt-alpha),
45
+ which is more suitable for both training and inference and for which most advanced diffusion sampler like [SA-Solver](https://arxiv.org/abs/2309.05019) will be added over time.
46
+ [Hugging Face](https://huggingface.co/spaces/PixArt-alpha/PixArt-alpha) provides free Pixart-α inference.
47
+ - **Repository:** https://github.com/PixArt-alpha/PixArt-alpha
48
+ - **Demo:** https://huggingface.co/spaces/PixArt-alpha/PixArt-alpha
49
+
50
+ # 🔥🔥🔥 Why PixArt-α?
51
+ ## Training Efficiency
52
+ PixArt-α only takes 10.8% of Stable Diffusion v1.5's training time (675 vs. 6,250 A100 GPU days), saving nearly $300,000 ($26,000 vs. $320,000) and reducing 90% CO2 emissions. Moreover, compared with a larger SOTA model, RAPHAEL, our training cost is merely 1%.
53
+ ![Training Efficiency.](asset/images/efficiency.svg)
54
+
55
+ | Method | Type | #Params | #Images | A100 GPU days |
56
+ |-----------|------|---------|---------|---------------|
57
+ | DALL·E | Diff | 12.0B | 1.54B | |
58
+ | GLIDE | Diff | 5.0B | 5.94B | |
59
+ | LDM | Diff | 1.4B | 0.27B | |
60
+ | DALL·E 2 | Diff | 6.5B | 5.63B | 41,66 |
61
+ | SDv1.5 | Diff | 0.9B | 3.16B | 6,250 |
62
+ | GigaGAN | GAN | 0.9B | 0.98B | 4,783 |
63
+ | Imagen | Diff | 3.0B | 15.36B | 7,132 |
64
+ | RAPHAEL | Diff | 3.0B | 5.0B | 60,000 |
65
+ | PixArt-α | Diff | 0.6B | 0.025B | 675 |
66
+
67
+
68
+ ## Evaluation
69
+ ![comparison](asset/images/user-study.png)
70
+ The chart above evaluates user preference for Pixart-α over SDXL 0.9, Stable Diffusion 2, DALLE-2 and DeepFloyd.
71
+ The Pixart-α base model performs comparable or even better than the existing state-of-the-art models.
72
+
73
+
74
+
75
+ ### 🧨 Diffusers
76
+
77
+ Make sure to upgrade diffusers to >= 0.22.0:
78
+ ```
79
+ pip install -U diffusers --upgrade
80
+ ```
81
+
82
+ In addition make sure to install `transformers`, `safetensors`, `sentencepiece`, and `accelerate`:
83
+ ```
84
+ pip install transformers accelerate safetensors sentencepiece
85
+ ```
86
+
87
+ To just use the base model, you can run:
88
+
89
+
90
+ ```py
91
+ from diffusers import PixArtAlphaPipeline
92
+ import torch
93
+
94
+ pipe = PixArtAlphaPipeline.from_pretrained("PixArt-alpha/PixArt-XL-2-1024-MS", torch_dtype=torch.float16)
95
+ pipe = pipe.to("cuda")
96
+
97
+ # if using torch < 2.0
98
+ # pipe.enable_xformers_memory_efficient_attention()
99
+
100
+ prompt = "An astronaut riding a green horse"
101
+ images = pipe(prompt=prompt).images[0]
102
+ ```
103
+
104
+ When using `torch >= 2.0`, you can improve the inference speed by 20-30% with torch.compile. Simple wrap the unet with torch compile before running the pipeline:
105
+ ```py
106
+ pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead", fullgraph=True)
107
+ ```
108
+
109
+ If you are limited by GPU VRAM, you can enable *cpu offloading* by calling `pipe.enable_model_cpu_offload`
110
+ instead of `.to("cuda")`:
111
+
112
+ ```diff
113
+ - pipe.to("cuda")
114
+ + pipe.enable_model_cpu_offload()
115
+ ```
116
+
117
+ For more information on how to use Pixart-α with `diffusers`, please have a look at [the Pixart-α Docs](https://huggingface.co/docs/diffusers/main/en/api/pipelines/pixart).
118
+
119
+ ### Free Google Colab
120
+ You can use Google Colab to generate images from PixArt-α free of charge. Click [here](https://colab.research.google.com/drive/1jZ5UZXk7tcpTfVwnX33dDuefNMcnW9ME?usp=sharing) too try.
121
+
122
+ ## Uses
123
+
124
+ ### Direct Use
125
+
126
+ The model is intended for research purposes only. Possible research areas and tasks include
127
+
128
+ - Generation of artworks and use in design and other artistic processes.
129
+ - Applications in educational or creative tools.
130
+ - Research on generative models.
131
+ - Safe deployment of models which have the potential to generate harmful content.
132
+
133
+ - Probing and understanding the limitations and biases of generative models.
134
+
135
+ Excluded uses are described below.
136
+
137
+ ### Out-of-Scope Use
138
+
139
+ The model was not trained to be factual or true representations of people or events, and therefore using the model to generate such content is out-of-scope for the abilities of this model.
140
+
141
+ ## Limitations and Bias
142
+
143
+ ### Limitations
144
+
145
+
146
+ - The model does not achieve perfect photorealism
147
+ - The model cannot render legible text
148
+ - The model struggles with more difficult tasks which involve compositionality, such as rendering an image corresponding to “A red cube on top of a blue sphere”
149
+ - fingers, .etc in general may not be generated properly.
150
+ - The autoencoding part of the model is lossy.
151
+
152
+ ### Bias
153
+ While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.