1from diffusers import AutoPipelineForText2Image
2import torch
3from huggingface_hub import hf_hub_download
4from safetensors.torch import load_file
5
6pipeline = AutoPipelineForText2Image.from_pretrained('stabilityai/stable-diffusion-xl-base-1.0', torch_dtype=torch.float16).to('cuda')
7pipeline.load_lora_weights('GoHugo/hugo', weight_name='pytorch_lora_weights.safetensors')
8embedding_path = hf_hub_download(repo_id='GoHugo/hugo', filename='hugo_emb.safetensors' repo_type="model")
9state_dict = load_file(embedding_path)
10pipeline.load_textual_inversion(state_dict["clip_l"], token=["<s0>", "<s1>"], text_encoder=pipeline.text_encoder, tokenizer=pipeline.tokenizer)
11pipeline.load_textual_inversion(state_dict["clip_g"], token=["<s0>", "<s1>"], text_encoder=pipeline.text_encoder_2, tokenizer=pipeline.tokenizer_2)
12
13image = pipeline('A photo of <s0><s1>').images[0]
For more details, including weighting, merging and fusing LoRAs, check the
documentation on loading LoRAs in diffusers
To trigger image generation of trained concept(or concepts) replace each concept identifier in you prompt with the new inserted tokens:
LoRA for the text encoder was enabled. False.
Pivotal tuning was enabled: True.
Special VAE used for training: madebyollin/sdxl-vae-fp16-fix.