p1atdev / LECO

Low-rank adaptation for Erasing COncepts from diffusion models.
https://arxiv.org/abs/2303.07345
Apache License 2.0
307 stars 23 forks source link

Question about the training code #25

Closed Hzj199 closed 1 year ago

Hzj199 commented 1 year ago

I have a question about the training code, what is the role of the "with network"?

p1atdev commented 1 year ago

In the "with network" block, this method in below will be called, and the lora multiplier will be 1.0 so the weight will applied. After the block, the multiplier will be 0.0 and the lora will be de-applied.

https://github.com/p1atdev/LECO/blob/02d41284ab25836846ed047b5c6e486f97c3e7e4/lora.py#L231-L237

By using this block, we don't have to prepare two U-Net models, just one U-Net is enough to train.

Hzj199 commented 1 year ago

In the "with network" block, this method in below will be called, and the lora multiplier will be 1.0 so the weight will applied. After the block, the multiplier will be 0.0 and the lora will be de-applied.

https://github.com/p1atdev/LECO/blob/02d41284ab25836846ed047b5c6e486f97c3e7e4/lora.py#L231-L237

By using this block, we don't have to prepare two U-Net models, just one U-Net is enough to train.

You've been a big help, thank you.

Hzj199 commented 1 year ago

In the "with network" block, this method in below will be called, and the lora multiplier will be 1.0 so the weight will applied. After the block, the multiplier will be 0.0 and the lora will be de-applied.

https://github.com/p1atdev/LECO/blob/02d41284ab25836846ed047b5c6e486f97c3e7e4/lora.py#L231-L237

By using this block, we don't have to prepare two U-Net models, just one U-Net is enough to train.

You've been a big help, thank you.