CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
67.75k stars 10.11k forks source link

Gradient Vanish when I import load_model_from_config function from scripts.txt2img #804

Open jin-qq opened 11 months ago

jin-qq commented 11 months ago

When I tried to finetune stable-diffusion, I import the load_model_from_config from scripts.txt2img, I found that gradient value equal to None even if require grad==True. When I import load_model_from_config, I create a MLP network (only one nn.Linear layer), this network do not have gradient as well. However, if I do not import load_model_from_config or any function from scripts.txt2img, MLP network have grandient and can be trained.

jin-qq commented 11 months ago

If I use https://github.com/facebookresearch/stable_signature/blob/main/utils_model.py#L134 to replace load_model_from_config , my other network have gradient and can be trained but stable-diffusion does not have gradient.