This file contains hidden or 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
# This script provides a function to convert the key format of LoRA weights from Xlabs to the format used by | |
# Hugging Face's Diffusers library. The conversion is necessary for utilizing Xlabs LoRA weights in models | |
# compatible with the Diffusers ecosystem. The script reads a LoRA weight file in safetensors format, | |
# converts the keys using predefined rules, and outputs the converted state dictionary. | |
import re | |
import torch | |
import safetensors.torch | |
from diffusers.loaders.single_file_utils import swap_scale_shift |