Skip to content

Using load_textual_inversion appears to do nothing #3097

@sakistriker

Description

@sakistriker

Describe the bug

When using load_textual_inversion it does not affect inference in any way. I provided a version of the modified sample code from the docs. I am using the embedding from CivitAI as described. I run once without loading the textual inversion and once with, they produce the same image. Am I missing something? Thanks for the help.

Reproduction

from diffusers import StableDiffusionPipeline
import torch

model_id = "runwayml/stable-diffusion-v1-5"

# Without Textural Inversion
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")

prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details."
generator = torch.Generator("cuda").manual_seed(1)

image = pipe(prompt, num_inference_steps=50, generator = generator).images[0]
display(image)

# With Textural Inversion
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16).to("cuda")
pipe.load_textual_inversion("/content/charturnerv2.pt")

prompt = "charturnerv2, multiple views of the same character in the same outfit, a character turnaround of a woman wearing a black jacket and red shirt, best quality, intricate details."
generator = torch.Generator("cuda").manual_seed(1)

image = pipe(prompt, num_inference_steps=50, generator = generator).images[0]
display(image)

Logs

No response

System Info

  • diffusers version: 0.15.0
  • Platform: Linux-5.10.147+-x86_64-with-glibc2.31
  • Python version: 3.9.16
  • PyTorch version (GPU?): 1.13.1+cu116 (True)
  • Huggingface_hub version: 0.13.4
  • Transformers version: 4.28.0
  • Accelerate version: 0.18.0
  • xFormers version: 0.0.16
  • Running on Google Colab with NVIDIA Tesla T4 GPU

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingstaleIssues that haven't received updates

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions