Here is some code for using LORAs with this

#7
by megachad - opened
This comment has been hidden
megachad changed discussion title from To use Loras to To use Loras with this
megachad changed discussion title from To use Loras with this to Here is some code for using LORAs with this

Using lora with this model is very interesting. Im going to try this tomorrow, I Am a beginner in this theme, so I will be happy to see any help. Thanks!

This comment has been hidden

Just use adapters exactly as you would with SDXL.

load up all your weights and give them names

    lorapath="whatever_directory/your_lora.safetensors"
    model.load_lora_weights(lorapath,
                            weight_name=lorapath,
                            torch_dtype=torch.float16,
                            local_files_only=True,
                            use_safetensors=True,
                            adapter_name=whatever_you_want_to_name_it,
                            variant="fp16",
                            vae=model.vae,
    )

Then set them as active and set weights

list_of_lora_names=["lora1", "another_lora", "etc"]
list_of_lora_weights = [1.0,.8,.7]

model.set_adapters(list_of_lora_names,adapter_weights=list_of_lora_weights)

You can show what loras are currently loaded:

current_loras = model.get_active_adapters()

and you can delete specific ones:

to_remove=["another_lora","etc"]
 model.delete_adapters(to_remove)

Sign up or log in to comment