KEMBAR78
Size from network weights by AI-Casanova · Pull Request #491 · kohya-ss/sd-scripts · GitHub
Skip to content

Conversation

@AI-Casanova
Copy link
Contributor

This PR add the --size_from_weights flag to override --dim and blockdims and directly loads the previously trained LoRA no matter the shape.

This allows finetuning a LoRA that has been resized with resize_lora.py (see #243) or with an unknown blockdims shape.

My Current Workflow:

  • Train LoRA with dim=128
  • Use sd-webui-lora-block-weight and sd-webui-supermerger to tweak block weights
  • Use resize_lora.py with --dynamic_method="sv_ratio" --dynamic_param=(between 10 and 20) to greatly reduce size and untrained noise.
  • Use this PR with lr cut in half to retrain the smaller LoRA, this seems to do a great job in cleaning up small details like eyes.

There may be a better way to handle the interpretation of block lrs. since there isn't a separate function in lora.py to call.

@kohya-ss
Copy link
Owner

Thank you for this. I think this feature is quite useful!

It seems to me that the parsing net_kwargs would be better to be common with lora.py. I will check and merge as soon as I get time.

@AI-Casanova
Copy link
Contributor Author

Agreed on the parsing function.

Cheers!

@kohya-ss kohya-ss changed the base branch from main to dev May 11, 2023 12:06
@kohya-ss kohya-ss merged commit a598225 into kohya-ss:dev May 11, 2023
@kohya-ss
Copy link
Owner

I'd like to rename the option to --dim_from_weights. I think it will be more intuitive. I appreciate your understanding.

@AI-Casanova
Copy link
Contributor Author

You are always welcome to make any and all changes to my PRs. I find things that are useful to me and share them, but I am in no means a great programmer.

@xdfeng07
Copy link

Hi, can you give some examples or detailed description on how to use sd-webui-lora-block-weight and sd-webui-supermerger to tweak block weights? Thanks very much!

@AI-Casanova AI-Casanova deleted the size-from-weights branch June 21, 2023 02:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants