Skip to content

Instantly share code, notes, and snippets.

View Leommm-byte's full-sized avatar
👨‍💻

BIOKORO OGHENETEGA D. Leommm-byte

👨‍💻
View GitHub Profile
@Leommm-byte
Leommm-byte / convert_lora_keys.py
Last active August 28, 2024 15:32
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 …
# 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