You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We support training with the Min-SNR weighting strategy proposed in [Efficient Diffusion Training via Min-SNR Weighting Strategy](https://arxiv.org/abs/2303.09556) which helps to achieve faster convergence
161
+
by rebalancing the loss. In order to use it, one needs to set the `--snr_gamma` argument. The recommended
162
+
value when using it is 5.0.
163
+
164
+
You can find [this project on Weights and Biases](https://wandb.ai/sayakpaul/text2image-finetune-minsnr) that compares the loss surfaces of the following setups:
165
+
166
+
* Training without the Min-SNR weighting strategy
167
+
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 5.0)
168
+
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 1.0)
169
+
170
+
For our small Pokemons dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced.
171
+
172
+
Also, note that in this example, we either predict `epsilon` (i.e., the noise) or the `v_prediction`. For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds.
173
+
174
+
<Tipwarning={true}>
175
+
176
+
Training with Min-SNR weighting strategy is only supported in PyTorch.
177
+
178
+
</Tip>
179
+
158
180
## LoRA
159
181
160
182
You can also use Low-Rank Adaptation of Large Language Models (LoRA), a fine-tuning technique for accelerating training large models, for fine-tuning text-to-image models. For more details, take a look at the [LoRA training](lora#text-to-image) guide.
We support training with the Min-SNR weighting strategy proposed in [Efficient Diffusion Training via Min-SNR Weighting Strategy](https://arxiv.org/abs/2303.09556) which helps to achieve faster convergence
117
+
by rebalancing the loss. In order to use it, one needs to set the `--snr_gamma` argument. The recommended
118
+
value when using it is 5.0.
119
+
120
+
You can find [this project on Weights and Biases](https://wandb.ai/sayakpaul/text2image-finetune-minsnr) that compares the loss surfaces of the following setups:
121
+
122
+
* Training without the Min-SNR weighting strategy
123
+
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 5.0)
124
+
* Training with the Min-SNR weighting strategy (`snr_gamma` set to 1.0)
125
+
126
+
For our small Pokemons dataset, the effects of Min-SNR weighting strategy might not appear to be pronounced, but for larger datasets, we believe the effects will be more pronounced.
127
+
128
+
Also, note that in this example, we either predict `epsilon` (i.e., the noise) or the `v_prediction`. For both of these cases, the formulation of the Min-SNR weighting strategy that we have used holds.
129
+
114
130
## Training with LoRA
115
131
116
132
Low-Rank Adaption of Large Language Models was first introduced by Microsoft in [LoRA: Low-Rank Adaptation of Large Language Models](https://arxiv.org/abs/2106.09685) by *Edward J. Hu, Yelong Shen, Phillip Wallis, Zeyuan Allen-Zhu, Yuanzhi Li, Shean Wang, Lu Wang, Weizhu Chen*.
raiseValueError("xformers is not available. Make sure it is installed correctly")
412
495
496
+
defcompute_snr(timesteps):
497
+
"""
498
+
Computes SNR as per https://github.com/TiankaiHang/Min-SNR-Diffusion-Training/blob/521b624bd70c67cee4bdf49225915f5945a872e3/guided_diffusion/gaussian_diffusion.py#L847-L849
# Adapted from https://github.com/TiankaiHang/Min-SNR-Diffusion-Training/blob/521b624bd70c67cee4bdf49225915f5945a872e3/guided_diffusion/gaussian_diffusion.py#L1026
0 commit comments