Skip to content

StableDiffusionUpscalePipeline does not support embeds, but docs say it does #2891

@d1g1t

Description

@d1g1t

Describe the bug

Running the example code with compel gives

ValueError: `prompt` has to be of type `str` or `list` but is <class 'NoneType'>

at diffusers/pipelines/stable_diffusion/pipeline_stable_diffusion_upscale.py:321 in check_inputs

It appears check_inputs is ignoring the negative_prompt, prompt_embeds and negative_prompt_embeds

Docs suggest that embeds are supported

Reproduction

import requests
from PIL import Image
from io import BytesIO
from diffusers import StableDiffusionUpscalePipeline
import torch
from compel import Compel

# load model and scheduler
model_id = "stabilityai/stable-diffusion-x4-upscaler"
pipeline = StableDiffusionUpscalePipeline.from_pretrained(model_id, torch_dtype=torch.float16)
pipeline = pipeline.to("cuda")

# let's download an  image
url = "https://huggingface.co/datasets/hf-internal-testing/diffusers-images/resolve/main/sd2-upscale/low_res_cat.png"
response = requests.get(url)
low_res_img = Image.open(BytesIO(response.content)).convert("RGB")
low_res_img = low_res_img.resize((128, 128))

prompt = "a white cat"

compel = Compel(tokenizer=pipeline.tokenizer, text_encoder=pipeline.text_encoder)
conditioning = compel.build_conditioning_tensor(prompt)

upscaled_image = pipeline(prompt_embeds=conditioning, image=low_res_img).images[0]
upscaled_image.save("upsampled_cat.png")

Logs

No response

System Info

  • diffusers version: 0.15.0.dev0
  • Platform: Linux-5.15.0-67-generic-x86_64-with-glibc2.35
  • Python version: 3.10.6
  • PyTorch version (GPU?): 2.0.0+cu117 (True)
  • Huggingface_hub version: 0.13.3
  • Transformers version: 4.27.3
  • Accelerate version: 0.18.0
  • xFormers version: 0.0.17
  • Using GPU in script?: Yes
  • Using distributed or parallel set-up in script?: No

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions