vladmandic / automatic

SD.Next: Advanced Implementation of Stable Diffusion and other Diffusion-based generative image models
https://github.com/vladmandic/automatic
GNU Affero General Public License v3.0
5.62k stars 413 forks source link

[Feature]: LyCORIS OFT Support #2516

Closed v0xie closed 10 months ago

v0xie commented 11 months ago

Feature description

LyCORIS now has support for OFT networks in the dev branch, (https://github.com/KohakuBlueleaf/LyCORIS/blob/dev/lycoris/modules/diag_oft.py) so I thought I'd open a feature request here to give a heads-up.

I've got an open pull request on A1111 with support for LyCORIS OFT: https://github.com/AUTOMATIC1111/stable-diffusion-webui/pull/13692/files

The major differences between kohya-ss and LyCORIS OFT:

Thank you!

Version Platform Description

n/a

vladmandic commented 11 months ago

we already support lora oft, but i this is just slightly different. is there a trained lora that can be used for dev/test?

v0xie commented 11 months ago

Here's a diag-oft network and sample image. https://huggingface.co/v0xie/sdxl-oft_monster_toy/blob/main/monster_toy_diag-oft-000060.safetensors

monster_toy_oft_20231115234552_e000060_00_1

vladmandic commented 11 months ago

i took a quick look at integrating this, but i think it needs more work... i'm getting dtype mismatch in def calc_updown_kb and scenarios where out_dim is not set at all since block is none of the items in if/elif block in class NetworkModuleOFT

v0xie commented 11 months ago

Maybe the dtype error is related to the R = R * multiplier + torch.eye(self.block_size, device=orig_weight.device) line? That's the only line in the function without a dtype specifier.

You can probably set out_dim to num_blocks * block_size or self.oft_blocks.shape[0] * self.oft_blocks.shape[1] since those are necessarily divisible by the module's out_dim.

vladmandic commented 11 months ago

Maybe the dtype error is related to the R = R * multiplier + torch.eye(self.block_size, device=orig_weight.device) line? That's the only line in the function without a dtype specifier.

yes, thats the line and i've worked around it by moving cast from couple of lines below to above the block.

You can probably set out_dim to num_blocks * block_size or self.oft_blocks.shape[0] * self.oft_blocks.shape[1] since those are necessarily divisible by the module's out_dim.

i tried that and it passes, but it was still not producing results that i expected. need to dive deeper into this, but it will have to wait.

vladmandic commented 10 months ago

done in dev branch.