Lawrence-cj commited on
Commit
6f96354
1 Parent(s): 786c445

Update README.md

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