PommesPeter commited on
Commit
445dfa2
1 Parent(s): 8e2d449

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +238 -3
README.md CHANGED
@@ -1,3 +1,238 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ ---
4
+
5
+ # Lumina-Next-T2I
6
+
7
+ The `Lumina-Next-T2I` model that uses Next-DiT with a 2B parameters model as well as using [Gemma-2B](https://huggingface.co/google/gemma-2b) as a text encoder. Compared with `Lumina-T2I`, it has faster inference speed, richer generation style, and more multilingual support, etc.
8
+
9
+ Our generative model has `Next-DiT` as the backbone, the text encoder is the `Gemma` 2B model, and the VAE uses a version of `sdxl` fine-tuned by stabilityai.
10
+
11
+ - Generation Model: Next-DiT
12
+ - Text Encoder: Gemma 2B
13
+ - VAE: stabilityai/sd-vae-ft-sdxl
14
+
15
+ ## 📰 News
16
+
17
+ - [2024-5-12] 🚀🚀🚀 We release the next version of `Lumina-T2I`, called `Lumina-Next-T2I` for faster and lower memory usage image generation model.
18
+
19
+ ## 🎮 Model Zoo
20
+
21
+ More checkpoints of our model will be released soon~
22
+
23
+ | Resolution | Next-DiT Parameter| Text Encoder | Prediction | Download URL |
24
+ | ---------- | ----------------------- | ------------ | -----------|-------------- |
25
+ | 1024 | 2B | Gemma-2B | Rectified Flow | [hugging face](https://huggingface.co/Alpha-VLLM/Lumina-Next-T2I) |
26
+
27
+ ## Installation
28
+
29
+ Before installation, ensure that you have a working ``nvcc``
30
+
31
+ ```bash
32
+ # The command should work and show the same version number as in our case. (12.1 in our case).
33
+ nvcc --version
34
+ ```
35
+
36
+ On some outdated distros (e.g., CentOS 7), you may also want to check that a late enough version of
37
+ ``gcc`` is available
38
+
39
+ ```bash
40
+ # The command should work and show a version of at least 6.0.
41
+ # If not, consult distro-specific tutorials to obtain a newer version or build manually.
42
+ gcc --version
43
+ ```
44
+
45
+ Downloading Lumina-T2X repo from github:
46
+
47
+ ```bash
48
+ git clone https://github.com/Alpha-VLLM/Lumina-T2X
49
+ ```
50
+
51
+ ### 1. Create a conda environment and install PyTorch
52
+
53
+ Note: You may want to adjust the CUDA version [according to your driver version](https://docs.nvidia.com/deploy/cuda-compatibility/#default-to-minor-version).
54
+
55
+ ```bash
56
+ conda create -n Lumina_T2X -y
57
+ conda activate Lumina_T2X
58
+ conda install python=3.11 pytorch==2.1.0 torchvision==0.16.0 torchaudio==2.1.0 pytorch-cuda=12.1 -c pytorch -c nvidia -y
59
+ ```
60
+
61
+ ### 2. Install dependencies
62
+
63
+ ```bash
64
+ pip install diffusers fairscale accelerate tensorboard transformers gradio torchdiffeq click
65
+ ```
66
+
67
+ or you can use
68
+
69
+ ```bash
70
+ cd lumina_next_t2i
71
+ pip install -r requirements.txt
72
+ ```
73
+
74
+ ### 3. Install ``flash-attn``
75
+
76
+ ```bash
77
+ pip install flash-attn --no-build-isolation
78
+ ```
79
+
80
+ ### 4. Install [nvidia apex](https://github.com/nvidia/apex) (optional)
81
+
82
+ >[!Warning]
83
+ > While Apex can improve efficiency, it is *not* a must to make Lumina-T2X work.
84
+ >
85
+ > Note that Lumina-T2X works smoothly with either:
86
+ > + Apex not installed at all; OR
87
+ > + Apex successfully installed with CUDA and C++ extensions.
88
+ >
89
+ > However, it will fail when:
90
+ > + A Python-only build of Apex is installed.
91
+ >
92
+ > If the error `No module named 'fused_layer_norm_cuda'` appears, it typically means you are using a Python-only build of Apex. To resolve this, please run `pip uninstall apex`, and Lumina-T2X should then function correctly.
93
+
94
+ You can clone the repo and install following the official guidelines (note that we expect a full
95
+ build, i.e., with CUDA and C++ extensions)
96
+
97
+ ```bash
98
+ pip install ninja
99
+ git clone https://github.com/NVIDIA/apex
100
+ cd apex
101
+ # if pip >= 23.1 (ref: https://pip.pypa.io/en/stable/news/#v23-1) which supports multiple `--config-settings` with the same key...
102
+ pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --config-settings "--build-option=--cpp_ext" --config-settings "--build-option=--cuda_ext" ./
103
+ # otherwise
104
+ pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./
105
+ ```
106
+
107
+ ## Inference
108
+
109
+ To ensure that our generative model is ready to use right out of the box, we provide a user-friendly CLI program and a locally deployable Web Demo site.
110
+
111
+ ### CLI
112
+
113
+ 1. Install Lumina-T2I
114
+
115
+ ```bash
116
+ pip install -e .
117
+ ```
118
+
119
+ 2. Prepare the pretrained model
120
+
121
+ ⭐⭐ (Recommanded) you can use huggingface_cli downloading our model:
122
+
123
+ ```bash
124
+ huggingface-cli download --resume-download Alpha-VLLM/Lumina-T2I --local-dir /path/to/ckpt
125
+ ```
126
+
127
+ or using git for cloning the model you want to use:
128
+
129
+ ```bash
130
+ git clone https://huggingface.co/Alpha-VLLM/Lumina-T2I
131
+ ```
132
+
133
+ 1. Setting your personal inference configuration
134
+
135
+ Update your own personal inference settings to generate different styles of images, checking `config/infer/config.yaml` for detailed settings. Detailed config structure:
136
+
137
+ > `/path/to/ckpt` should be a directory containing `consolidated*.pth` and `model_args.pth`
138
+
139
+ ```yaml
140
+ - settings:
141
+
142
+ model:
143
+ ckpt: "/path/to/ckpt" # if ckpt is "", you should use `--ckpt` for passing model path when using `lumina` cli.
144
+ ckpt_lm: "" # if ckpt is "", you should use `--ckpt_lm` for passing model path when using `lumina` cli.
145
+ token: "" # if LLM is a huggingface gated repo, you should input your access token from huggingface and when token is "", you should `--token` for accessing the model.
146
+
147
+ transport:
148
+ path_type: "Linear" # option: ["Linear", "GVP", "VP"]
149
+ prediction: "velocity" # option: ["velocity", "score", "noise"]
150
+ loss_weight: "velocity" # option: [None, "velocity", "likelihood"]
151
+ sample_eps: 0.1
152
+ train_eps: 0.2
153
+
154
+ ode:
155
+ atol: 1e-6 # Absolute tolerance
156
+ rtol: 1e-3 # Relative tolerance
157
+ reverse: false # option: true or false
158
+ likelihood: false # option: true or false
159
+
160
+ sde:
161
+ sampling_method: "Euler" # option: ["Euler", "Heun"]
162
+ diffusion_form: "sigma" # option: ["constant", "SBDM", "sigma", "linear", "decreasing", "increasing-decreasing"]
163
+ diffusion_norm: 1.0 # range: 0-1
164
+ last_step: Mean # option: [None, "Mean", "Tweedie", "Euler"]
165
+ last_step_size: 0.04
166
+
167
+ infer:
168
+ resolution: "1024x1024" # option: ["1024x1024", "512x2048", "2048x512", "(Extrapolation) 1664x1664", "(Extrapolation) 1024x2048", "(Extrapolation) 2048x1024"]
169
+ num_sampling_steps: 60 # range: 1-1000
170
+ cfg_scale: 4. # range: 1-20
171
+ solver: "euler" # option: ["euler", "dopri5", "dopri8"]
172
+ t_shift: 4 # range: 1-20 (int only)
173
+ ntk_scaling: true # option: true or false
174
+ proportional_attn: true # option: true or false
175
+ seed: 0 # rnage: any number
176
+ ```
177
+
178
+ - model:
179
+ - `ckpt`: lumina-t2i checkpoint path from [huggingface repo](https://huggingface.co/Alpha-VLLM/Lumina-T2I) containing `consolidated*.pth` and `model_args.pth`.
180
+ - `ckpt_lm`: LLM checkpoint.
181
+ - `token`: huggingface access token for accessing gated repo.
182
+ - transport:
183
+ - `path_type`: the type of path for transport: 'Linear', 'GVP' (Geodesic Vector Pursuit), or 'VP' (Vector Pursuit).
184
+ - `prediction`: the prediction model for the transport dynamics.
185
+ - `loss_weight`: the weighting of different components in the loss function, can be 'velocity' for dynamic modeling, 'likelihood' for statistical consistency, or None for no weighting
186
+ - `sample_eps`: sampling in the transport model.
187
+ - `train_eps`: training to stabilize the learning process.
188
+ - ode:
189
+ - `atol`: Absolute tolerance for the ODE solver. (options: ["Linear", "GVP", "VP"])
190
+ - `rtol`: Relative tolerance for the ODE solver. (option: ["velocity", "score", "noise"])
191
+ - `reverse`: run the ODE solver in reverse. (option: [None, "velocity", "likelihood"])
192
+ - `likelihood`: Enable calculation of likelihood during the ODE solving process.
193
+ - sde
194
+ - `sampling-method`: the numerical method used for sampling the stochastic differential equation: 'Euler' for simplicity or 'Heun' for improved accuracy.
195
+ - `diffusion-form`: form of diffusion coefficient in the SDE
196
+ - `diffusion-norm`: Normalizes the diffusion coefficient, affecting the scale of the stochastic component.
197
+ - `last-step`: form of last step taken in the SDE
198
+ - `last-step-size`: size of the last step taken
199
+ - infer
200
+ - `resolution`: generated image resolution.
201
+ - `num_sampling_steps`: sampling step for generating image.
202
+ - `cfg_scale`: classifier-free guide scaling factor
203
+ - `solver`: solver for image generation.
204
+ - `t_shift`: time shift factor.
205
+ - `ntk_scaling`: ntk rope scaling factor.
206
+ - `proportional_attn`: Whether to use proportional attention.
207
+ - `seed`: random initialization seeds.
208
+
209
+ 1. Run with CLI
210
+
211
+ inference command:
212
+ ```bash
213
+ lumina_next infer -c <config_path> <caption_here> <output_dir>
214
+ ```
215
+
216
+ e.g. Demo command:
217
+
218
+ ```bash
219
+ cd lumina_next_t2i
220
+ lumina_next infer -c "config/infer/settings.yaml" "a snow man of ..." "./outputs"
221
+ ```
222
+
223
+ ### Web Demo
224
+
225
+ To host a local gradio demo for interactive inference, run the following command:
226
+
227
+ ```bash
228
+ # `/path/to/ckpt` should be a directory containing `consolidated*.pth` and `model_args.pth`
229
+
230
+ # default
231
+ python -u demo.py --ckpt "/path/to/ckpt"
232
+
233
+ # the demo by default uses bf16 precision. to switch to fp32:
234
+ python -u demo.py --ckpt "/path/to/ckpt" --precision fp32
235
+
236
+ # use ema model
237
+ python -u demo.py --ckpt "/path/to/ckpt" --ema
238
+ ```