Lawrence-cj
commited on
Commit
•
e102b35
1
Parent(s):
937eb4b
add PixArt-Sigma model card
Browse files- .gitattributes +1 -0
- README.md +129 -1
- asset/4K_image.jpg +3 -0
- asset/logo-sigma.png +0 -0
- asset/model.png +0 -0
.gitattributes
CHANGED
@@ -33,3 +33,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
33 |
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
36 |
+
asset/4K_image.jpg filter=lfs diff=lfs merge=lfs -text
|
README.md
CHANGED
@@ -1,3 +1,131 @@
|
|
1 |
---
|
2 |
-
license: openrail
|
|
|
|
|
|
|
3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
---
|
2 |
+
license: openrail++
|
3 |
+
tags:
|
4 |
+
- text-to-image
|
5 |
+
- PixArt-Σ
|
6 |
---
|
7 |
+
|
8 |
+
<p align="center">
|
9 |
+
<img src="asset/logo-sigma.png" height=120>
|
10 |
+
</p>
|
11 |
+
|
12 |
+
<div style="display:flex;justify-content: center">
|
13 |
+
<a href="https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma"><img src="https://img.shields.io/static/v1?label=Demo&message=Huggingface&color=yellow"></a>  
|
14 |
+
<a href="https://pixart-alpha.github.io/PixArt-sigma-project/"><img src="https://img.shields.io/static/v1?label=Project%20Page&message=Github&color=blue&logo=github-pages"></a>  
|
15 |
+
<a href="https://arxiv.org/abs/2403.04692"><img src="https://img.shields.io/static/v1?label=Paper&message=Arxiv&color=red&logo=arxiv"></a>  
|
16 |
+
<a href="https://discord.gg/rde6eaE5Ta"><img src="https://img.shields.io/static/v1?label=Discuss&message=Discord&color=purple&logo=discord"></a>  
|
17 |
+
</div>
|
18 |
+
|
19 |
+
# 🐱 PixArt-Σ Model Card
|
20 |
+
![row01](asset/4K_image.jpg)
|
21 |
+
|
22 |
+
## Model
|
23 |
+
![pipeline](asset/model.png)
|
24 |
+
|
25 |
+
[PixArt-Σ](https://arxiv.org/abs/2403.04692) consists of pure transformer blocks for latent diffusion:
|
26 |
+
It can directly generate 1024px, 2K and 4K images from text prompts within a single sampling process.
|
27 |
+
|
28 |
+
Source code is available at https://github.com/PixArt-alpha/PixArt-sigma.
|
29 |
+
|
30 |
+
### Model Description
|
31 |
+
|
32 |
+
- **Developed by:** PixArt-Σ
|
33 |
+
- **Model type:** Diffusion-Transformer-based text-to-image generative model
|
34 |
+
- **License:** [CreativeML Open RAIL++-M License](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md)
|
35 |
+
- **Model Description:** This is a model that can be used to generate and modify images based on text prompts.
|
36 |
+
It is a [Transformer Latent Diffusion Model](https://arxiv.org/abs/2310.00426) that uses one fixed, pretrained text encoders ([T5](
|
37 |
+
https://huggingface.co/DeepFloyd/t5-v1_1-xxl))
|
38 |
+
and one latent feature encoder ([VAE](https://arxiv.org/abs/2112.10752)).
|
39 |
+
- **Resources for more information:** Check out our [GitHub Repository](https://github.com/PixArt-alpha/PixArt-sigma) and the [PixArt-Σ report on arXiv](https://arxiv.org/abs/2403.04692).
|
40 |
+
|
41 |
+
### Model Sources
|
42 |
+
|
43 |
+
For research purposes, we recommend our `generative-models` Github repository (https://github.com/PixArt-alpha/PixArt-sigma),
|
44 |
+
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.
|
45 |
+
[Hugging Face](https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma) provides free PixArt-Σ inference.
|
46 |
+
- **Repository:** https://github.com/PixArt-alpha/PixArt-sigma
|
47 |
+
- **Demo:** https://huggingface.co/spaces/PixArt-alpha/PixArt-Sigma
|
48 |
+
|
49 |
+
### 🧨 Diffusers
|
50 |
+
> [!IMPORTANT]
|
51 |
+
> Make sure to upgrade diffusers to >= 0.28.0:
|
52 |
+
> ```bash
|
53 |
+
> pip install -U diffusers --upgrade
|
54 |
+
> ```
|
55 |
+
> In addition make sure to install `transformers`, `safetensors`, `sentencepiece`, and `accelerate`:
|
56 |
+
> ```
|
57 |
+
> pip install transformers accelerate safetensors sentencepiece
|
58 |
+
> ```
|
59 |
+
> For `diffusers<0.28.0`, check this [script](https://github.com/PixArt-alpha/PixArt-sigma#2-integration-in-diffusers) for help.
|
60 |
+
|
61 |
+
To just use the base model, you can run:
|
62 |
+
|
63 |
+
```python
|
64 |
+
import torch
|
65 |
+
from diffusers import Transformer2DModel, PixArtSigmaPipeline
|
66 |
+
|
67 |
+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
|
68 |
+
weight_dtype = torch.float16
|
69 |
+
|
70 |
+
pipe = PixArtSigmaPipeline.from_pretrained(
|
71 |
+
"PixArt-alpha/PixArt-Sigma-XL-2-1024-MS",
|
72 |
+
torch_dtype=weight_dtype,
|
73 |
+
use_safetensors=True,
|
74 |
+
)
|
75 |
+
pipe.to(device)
|
76 |
+
|
77 |
+
# Enable memory optimizations.
|
78 |
+
# pipe.enable_model_cpu_offload()
|
79 |
+
|
80 |
+
prompt = "A small cactus with a happy face in the Sahara desert."
|
81 |
+
image = pipe(prompt).images[0]
|
82 |
+
image.save("./catcus.png")
|
83 |
+
```
|
84 |
+
|
85 |
+
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:
|
86 |
+
```py
|
87 |
+
pipe.transformer = torch.compile(pipe.transformer, mode="reduce-overhead", fullgraph=True)
|
88 |
+
```
|
89 |
+
|
90 |
+
If you are limited by GPU VRAM, you can enable *cpu offloading* by calling `pipe.enable_model_cpu_offload`
|
91 |
+
instead of `.to("cuda")`:
|
92 |
+
|
93 |
+
```diff
|
94 |
+
- pipe.to("cuda")
|
95 |
+
+ pipe.enable_model_cpu_offload()
|
96 |
+
```
|
97 |
+
|
98 |
+
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_sigma.md).
|
99 |
+
|
100 |
+
## Uses
|
101 |
+
|
102 |
+
### Direct Use
|
103 |
+
|
104 |
+
The model is intended for research purposes only. Possible research areas and tasks include
|
105 |
+
|
106 |
+
- Generation of artworks and use in design and other artistic processes.
|
107 |
+
- Applications in educational or creative tools.
|
108 |
+
- Research on generative models.
|
109 |
+
- Safe deployment of models which have the potential to generate harmful content.
|
110 |
+
|
111 |
+
- Probing and understanding the limitations and biases of generative models.
|
112 |
+
|
113 |
+
Excluded uses are described below.
|
114 |
+
|
115 |
+
### Out-of-Scope Use
|
116 |
+
|
117 |
+
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.
|
118 |
+
|
119 |
+
## Limitations and Bias
|
120 |
+
|
121 |
+
### Limitations
|
122 |
+
|
123 |
+
|
124 |
+
- The model does not achieve perfect photorealism
|
125 |
+
- The model cannot render legible text
|
126 |
+
- 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”
|
127 |
+
- fingers, .etc in general may not be generated properly.
|
128 |
+
- The autoencoding part of the model is lossy.
|
129 |
+
|
130 |
+
### Bias
|
131 |
+
While the capabilities of image generation models are impressive, they can also reinforce or exacerbate social biases.
|
asset/4K_image.jpg
ADDED
Git LFS Details
|
asset/logo-sigma.png
ADDED
asset/model.png
ADDED