Text-to-Image
Diffusers
Safetensors
PommesPeter commited on
Commit
b436972
โ€ข
1 Parent(s): fda6ae0

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +219 -3
README.md CHANGED
@@ -1,3 +1,219 @@
1
- ---
2
- license: apache-2.0
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: apache-2.0
3
+ tags:
4
+ - text-to-image
5
+ - safetensors
6
+ - diffusers
7
+ datasets:
8
+ - JourneyDB/JourneyDB
9
+ library_name: diffusers
10
+ pipeline_tag: text-to-image
11
+ ---
12
+
13
+ # Lumina-Next-SFT
14
+
15
+ The `Lumina-Next-SFT` is a Next-DiT model containing 2B parameters and utilizes [Gemma-2B](https://huggingface.co/google/gemma-2b) as the text encoder, enhanced through high-quality supervised fine-tuning (SFT).
16
+
17
+ 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.
18
+
19
+ - Generation Model: Next-DiT
20
+ - Text Encoder: [Gemma-2B](https://huggingface.co/google/gemma-2b)
21
+ - VAE: [stabilityai/sdxl-vae](https://huggingface.co/stabilityai/sdxl-vae)
22
+
23
+ [paper](https://arxiv.org/abs/2405.05945)
24
+
25
+ ## ๐Ÿ“ฐ News
26
+
27
+ - [2024-06-21] ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ We have supported diffusers to load the `Lumina-Next-SFT` model. https://huggingface.co/Alpha-VLLM/Lumina-Next-SFT-diffusers
28
+
29
+ - [2024-06-08] ๐ŸŽ‰๐ŸŽ‰๐ŸŽ‰ We have released the `Lumina-Next-SFT` model.
30
+
31
+ - [2024-05-28] We updated the `Lumina-Next-T2I` model to support 2K Resolution image generation.
32
+
33
+ - [2024-05-16] We have converted the `.pth` weights to `.safetensors` weights. Please pull the latest code to use `demo.py` for inference.
34
+
35
+ - [2024-05-12] We release the next version of `Lumina-T2I`, called `Lumina-Next-T2I` for faster and lower memory usage image generation model.
36
+
37
+ ## ๐ŸŽฎ Model Zoo
38
+
39
+ More checkpoints of our model will be released soon~
40
+
41
+ | Resolution | Next-DiT Parameter| Text Encoder | Prediction | Download URL |
42
+ | ---------- | ----------------------- | ------------ | -----------|-------------- |
43
+ | 1024 | 2B | [Gemma-2B](https://huggingface.co/google/gemma-2b) | Rectified Flow | [hugging face](https://huggingface.co/Alpha-VLLM/Lumina-Next-SFT) |
44
+
45
+ ## Installation
46
+
47
+ Before installation, ensure that you have a working ``nvcc``
48
+
49
+ ```bash
50
+ # The command should work and show the same version number as in our case. (12.1 in our case).
51
+ nvcc --version
52
+ ```
53
+
54
+ On some outdated distros (e.g., CentOS 7), you may also want to check that a late enough version of
55
+ ``gcc`` is available
56
+
57
+ ```bash
58
+ # The command should work and show a version of at least 6.0.
59
+ # If not, consult distro-specific tutorials to obtain a newer version or build manually.
60
+ gcc --version
61
+ ```
62
+
63
+ Downloading Lumina-T2X repo from GitHub:
64
+
65
+ ```bash
66
+ git clone https://github.com/Alpha-VLLM/Lumina-T2X
67
+ ```
68
+
69
+ ### 1. Create a conda environment and install PyTorch
70
+
71
+ 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).
72
+
73
+ ```bash
74
+ conda create -n Lumina_T2X -y
75
+ conda activate Lumina_T2X
76
+ 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
77
+ ```
78
+
79
+ ### 2. Install dependencies
80
+
81
+ ```bash
82
+ pip install diffusers fairscale accelerate tensorboard transformers gradio torchdiffeq click
83
+ ```
84
+
85
+ or you can use
86
+
87
+ ```bash
88
+ cd lumina_next_t2i
89
+ pip install -r requirements.txt
90
+ ```
91
+
92
+ ### 3. Install ``flash-attn``
93
+
94
+ ```bash
95
+ pip install flash-attn --no-build-isolation
96
+ ```
97
+
98
+ ### 4. Install [nvidia apex](https://github.com/nvidia/apex) (optional)
99
+
100
+ >[!Warning]
101
+ > While Apex can improve efficiency, it is *not* a must to make Lumina-T2X work.
102
+ >
103
+ > Note that Lumina-T2X works smoothly with either:
104
+ > + Apex not installed at all; OR
105
+ > + Apex successfully installed with CUDA and C++ extensions.
106
+ >
107
+ > However, it will fail when:
108
+ > + A Python-only build of Apex is installed.
109
+ >
110
+ > 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.
111
+
112
+ You can clone the repo and install following the official guidelines (note that we expect a full
113
+ build, i.e., with CUDA and C++ extensions)
114
+
115
+ ```bash
116
+ pip install ninja
117
+ git clone https://github.com/NVIDIA/apex
118
+ cd apex
119
+ # if pip >= 23.1 (ref: https://pip.pypa.io/en/stable/news/#v23-1) which supports multiple `--config-settings` with the same key...
120
+ 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" ./
121
+ # otherwise
122
+ pip install -v --disable-pip-version-check --no-cache-dir --no-build-isolation --global-option="--cpp_ext" --global-option="--cuda_ext" ./
123
+ ```
124
+
125
+ ## Inference
126
+
127
+ 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.
128
+
129
+ ### CLI
130
+
131
+ 1. Install Lumina-Next-T2I
132
+
133
+ ```bash
134
+ pip install -e .
135
+ ```
136
+
137
+ 2. Prepare the pre-trained model
138
+
139
+ โญโญ (Recommended) you can use huggingface_cli to download our model:
140
+
141
+ ```bash
142
+ huggingface-cli download --resume-download Alpha-VLLM/Lumina-Next-SFT --local-dir /path/to/ckpt
143
+ ```
144
+
145
+ or using git for cloning the model you want to use:
146
+
147
+ ```bash
148
+ git clone https://huggingface.co/Alpha-VLLM/Lumina-Next-T2I
149
+ ```
150
+
151
+ 1. Setting your personal inference configuration
152
+
153
+ Update your own personal inference settings to generate different styles of images, checking `config/infer/config.yaml` for detailed settings. Detailed config structure:
154
+
155
+ > `/path/to/ckpt` should be a directory containing `consolidated*.pth` and `model_args.pth`
156
+
157
+ ```yaml
158
+ - settings:
159
+
160
+ model:
161
+ ckpt: ""
162
+ ckpt_lm: ""
163
+ token: ""
164
+
165
+ transport:
166
+ path_type: "Linear" # option: ["Linear", "GVP", "VP"]
167
+ prediction: "velocity" # option: ["velocity", "score", "noise"]
168
+ loss_weight: "velocity" # option: [None, "velocity", "likelihood"]
169
+ sample_eps: 0.1
170
+ train_eps: 0.2
171
+
172
+ ode:
173
+ atol: 1e-6 # Absolute tolerance
174
+ rtol: 1e-3 # Relative tolerance
175
+ reverse: false # option: true or false
176
+ likelihood: false # option: true or false
177
+
178
+ infer:
179
+ resolution: "1024x1024" # option: ["1024x1024", "512x2048", "2048x512", "(Extrapolation) 1664x1664", "(Extrapolation) 1024x2048", "(Extrapolation) 2048x1024"]
180
+ num_sampling_steps: 60 # range: 1-1000
181
+ cfg_scale: 4. # range: 1-20
182
+ solver: "euler" # option: ["euler", "dopri5", "dopri8"]
183
+ t_shift: 4 # range: 1-20 (int only)
184
+ scaling_method: "Time-aware" # option: ["Time-aware", "None"]
185
+ scale_watershed: 0.3 # range: 0.0-1.0
186
+ proportional_attn: true # option: true or false
187
+ seed: 0 # rnage: any number
188
+ ```
189
+
190
+ 1. Run with CLI
191
+
192
+ inference command:
193
+ ```bash
194
+ lumina_next infer -c <config_path> <caption_here> <output_dir>
195
+ ```
196
+
197
+ e.g. Demo command:
198
+
199
+ ```bash
200
+ cd lumina_next_t2i
201
+ lumina_next infer -c "config/infer/settings.yaml" "a snowman of ..." "./outputs"
202
+ ```
203
+
204
+ ### Web Demo
205
+
206
+ To host a local gradio demo for interactive inference, run the following command:
207
+
208
+ ```bash
209
+ # `/path/to/ckpt` should be a directory containing `consolidated*.pth` and `model_args.pth`
210
+
211
+ # default
212
+ python -u demo.py --ckpt "/path/to/ckpt"
213
+
214
+ # the demo by default uses bf16 precision. to switch to fp32:
215
+ python -u demo.py --ckpt "/path/to/ckpt" --precision fp32
216
+
217
+ # use ema model
218
+ python -u demo.py --ckpt "/path/to/ckpt" --ema
219
+ ```