kohya-ss / sd-scripts

Apache License 2.0
5.18k stars 860 forks source link

Resizing LoRA produces unusable model #904

Open iScriptLex opened 1 year ago

iScriptLex commented 1 year ago

When I change the size of LoRA with this script:

python3 "networks/resize_lora.py" --save_precision fp16 \
                         --save_to "/models/Lora/ling_v3_a16.safetensors" \
                         --model "/models/Lora/ling_v3_a.safetensors" \
                         --new_rank 16 \
                         --device cuda --dynamic_method sv_fro --dynamic_param  0.9 \
                         --verbose

regardless of the selected "new_rank", the size of the resulting file is only about 8MB. And when I try to use this file in the AUTOMATIC1111 WebUI an error appears:

RuntimeError: output with shape [3072, 1] doesn't match the broadcast shape [3072, 3072]

So, resizer (networks/resize_lora.py) can't make working LoRA. Any result of resizing is corrupted and just doesn't work.

Example of LoRA, which I used as a source for resizing: https://drive.google.com/file/d/1Z3F3uI6T9JDB6ZXzwaYB9-QtkzS6zpwq/view?usp=drive_link

feffy380 commented 1 year ago
--device cuda

I've had trouble resizing via gpu before. Try cpu instead. That works reliably for my loras

iScriptLex commented 1 year ago

Try cpu instead

Thank you, it works now!