This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Convert cloneofsimo lora format to AUTOMATIC1111 webui format (kohya's format) | |
# Will generate extra embedding files along with the converted lora | |
# Usage: python lora_convert.py path_to_lora output_folder [--overwrite] | |
# path_to_lora_file : path to lora safetensors in cloneofsimo lora format | |
# output_folder : path to folder for results in AUTOMATIC1111 webui format | |
# overwrite : overwrite the results in output_folder | |
# Example: python lora_convert.py .\lora_krk.safetensors .\ | |
from safetensors import safe_open | |
from safetensors.torch import save_file |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from safetensors import safe_open | |
from safetensors.torch import save_file | |
def layer_name(i): | |
if i.startswith('lora_te_text_model_encoder_layers_'): | |
idx = int(i[34:].split('_')[0]) | |
return f'text' | |
elif i.startswith('lora_unet_down_blocks_'): | |
idx0 = int(i[22:].split('_')[0]) | |
idx1 = int(i[22:].split('_')[2]) |