Lawrence-cj
commited on
Commit
•
4005a92
1
Parent(s):
f395921
First add PixArt-LCM model card.
Browse files- .DS_Store +0 -0
- README.md +127 -1
- asset/model.png +0 -0
- asset/pixart-lcm2.png +0 -0
.DS_Store
ADDED
Binary file (10.2 kB). View file
|
|
README.md
CHANGED
@@ -1,3 +1,129 @@
|
|
1 |
---
|
2 |
license: openrail++
|
3 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
license: openrail++
|
3 |
+
tags:
|
4 |
+
- text-to-image
|
5 |
+
- Pixart-α
|
6 |
+
- LCM
|
7 |
+
---
|
8 |
+
|
9 |
+
<p align="center">
|
10 |
+
<img src="asset/pixart-lcm2.png" height=120>
|
11 |
+
</p>
|
12 |
+
|
13 |
+
<div style="display:flex;justify-content: center">
|
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>  
|
15 |
+
<a href="https://huggingface.co/spaces/PixArt-alpha/PixArt-alpha"><img src="https://img.shields.io/static/v1?label=Demo PixArt&message=HuggingFace&color=yellow"></a>  
|
16 |
+
<a href="https://huggingface.co/spaces/PixArt-alpha/PixArt-LCM"><img src="https://img.shields.io/static/v1?label=Demo PixArt-LCM&message=HuggingFace&color=yellow"></a>  
|
17 |
+
<a href="https://arxiv.org/abs/2310.00426"><img src="https://img.shields.io/static/v1?label=PixArt&message=Arxiv&color=red&logo=arxiv"></a>  
|
18 |
+
<a href="https://arxiv.org/abs/2310.04378"><img src="https://img.shields.io/static/v1?label=LCM&message=Arxiv&color=red&logo=arxiv"></a>  
|
19 |
+
<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>  
|
20 |
+
</div>
|
21 |
+
|
22 |
+
# 🐱 Pixart-LCM Model Card
|
23 |
+
## Model
|
24 |
+
![pipeline](asset/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 |
+
[LCMs](https://arxiv.org/abs/2310.04378) is a diffusion distillation method which predict PF-ODE's solution directly in latent space, achieving super fast inference with few steps.
|
30 |
+
|
31 |
+
Source code of PixArt-LCM is available at https://github.com/PixArt-alpha/PixArt-alpha.
|
32 |
+
|
33 |
+
### Model Description
|
34 |
+
|
35 |
+
- **Developed by:** Pixart & LCM teams
|
36 |
+
- **Model type:** Diffusion-Transformer-based text-to-image generative model
|
37 |
+
- **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
|
38 |
+
- **Model Description:** This is a model that can be used to generate and modify images based on text prompts.
|
39 |
+
It is a [Transformer Latent Diffusion Model](https://arxiv.org/abs/2310.00426) that uses one fixed, pretrained text encoders ([T5](
|
40 |
+
https://huggingface.co/DeepFloyd/t5-v1_1-xxl))
|
41 |
+
and one latent feature encoder ([VAE](https://arxiv.org/abs/2112.10752)).
|
42 |
+
- **Resources for more information:** Check out our [PixArt-α](https://github.com/PixArt-alpha/PixArt-alpha), [LCM](https://github.com/luosiallen/latent-consistency-model) GitHub Repository
|
43 |
+
and the [Pixart-α](https://arxiv.org/abs/2310.00426), [LCM](https://arxiv.org/abs/2310.04378) reports on arXiv.
|
44 |
+
|
45 |
+
### Model Sources
|
46 |
+
|
47 |
+
For research purposes, we recommend our `generative-models` Github repository (https://github.com/PixArt-alpha/PixArt-alpha),
|
48 |
+
which is more suitable for developing both training and inference designs.
|
49 |
+
[Hugging Face](https://huggingface.co/spaces/PixArt-alpha/PixArt-LCM) provides free Pixart-LCM inference.
|
50 |
+
- **Repository:** https://github.com/PixArt-alpha/PixArt-alpha
|
51 |
+
- **Demo:** https://huggingface.co/spaces/PixArt-alpha/PixArt-LCM
|
52 |
+
|
53 |
+
### 🧨 Diffusers
|
54 |
+
|
55 |
+
Make sure to upgrade diffusers to >= 0.23.0:
|
56 |
+
```
|
57 |
+
pip install -U diffusers --upgrade
|
58 |
+
```
|
59 |
+
|
60 |
+
In addition make sure to install `transformers`, `safetensors`, `sentencepiece`, and `accelerate`:
|
61 |
+
```
|
62 |
+
pip install transformers accelerate safetensors sentencepiece
|
63 |
+
```
|
64 |
+
|
65 |
+
To just use the base model, you can run:
|
66 |
+
|
67 |
+
|
68 |
+
```python
|
69 |
+
import torch
|
70 |
+
from diffusers import PixArtAlphaPipeline
|
71 |
+
|
72 |
+
# only 1024-MS version is supported for now
|
73 |
+
pipe = PixArtAlphaPipeline.from_pretrained("PixArt-alpha/PixArt-LCM-XL-2-1024-MS", torch_dtype=torch.float16, use_safetensors=True)
|
74 |
+
|
75 |
+
# Enable memory optimizations.
|
76 |
+
pipe.enable_model_cpu_offload()
|
77 |
+
|
78 |
+
prompt = "A small cactus with a happy face in the Sahara desert."
|
79 |
+
image = pipe(prompt).images[0]
|
80 |
+
```
|
81 |
+
|
82 |
+
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:
|
83 |
+
```py
|
84 |
+
pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead", fullgraph=True)
|
85 |
+
```
|
86 |
+
|
87 |
+
If you are limited by GPU VRAM, you can enable *cpu offloading* by calling `pipe.enable_model_cpu_offload`
|
88 |
+
instead of `.to("cuda")`:
|
89 |
+
|
90 |
+
```diff
|
91 |
+
- pipe.to("cuda")
|
92 |
+
+ pipe.enable_model_cpu_offload()
|
93 |
+
```
|
94 |
+
|
95 |
+
The diffusers use here is totally the same as the base-model PixArt-α.
|
96 |
+
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).
|
97 |
+
|
98 |
+
## Uses
|
99 |
+
|
100 |
+
### Direct Use
|
101 |
+
|
102 |
+
The model is intended for research purposes only. Possible research areas and tasks include
|
103 |
+
|
104 |
+
- Generation of artworks and use in design and other artistic processes.
|
105 |
+
- Applications in educational or creative tools.
|
106 |
+
- Research on generative models.
|
107 |
+
- Safe deployment of models which have the potential to generate harmful content.
|
108 |
+
|
109 |
+
- Probing and understanding the limitations and biases of generative models.
|
110 |
+
|
111 |
+
Excluded uses are described below.
|
112 |
+
|
113 |
+
### Out-of-Scope Use
|
114 |
+
|
115 |
+
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.
|
116 |
+
|
117 |
+
## Limitations and Bias
|
118 |
+
|
119 |
+
### Limitations
|
120 |
+
|
121 |
+
|
122 |
+
- The model does not achieve perfect photorealism
|
123 |
+
- The model cannot render legible text
|
124 |
+
- 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”
|
125 |
+
- fingers, .etc in general may not be generated properly.
|
126 |
+
- The autoencoding part of the model is lossy.
|
127 |
+
|
128 |
+
### Bias
|
129 |
+
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
|
asset/model.png
ADDED
asset/pixart-lcm2.png
ADDED