PommesPeter commited on
Commit
0268f76
1 Parent(s): 614912b

Update README.md

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