Skip to content

fix a bug in StableDiffusionUpscalePipeline when prompt is None #4278

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 27, 2023

Conversation

yiyixuxu
Copy link
Collaborator

fix a bug described here
#4249 (comment)

this example currently fails but will work with this fix

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

# load model and scheduler
model_id = "stabilityai/stable-diffusion-x4-upscaler"
pipeline = StableDiffusionUpscalePipeline.from_pretrained(
    model_id, revision="fp16", 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"

prompt_embeds = pipeline._encode_prompt(prompt, "cuda", 1, True)
prompt_embeds, _ = prompt_embeds.chunk(2)

upscaled_image = pipeline(image=[low_res_img] * 1, prompt_embeds = prompt_embeds).images[0]

@HuggingFaceDocBuilderDev
Copy link

HuggingFaceDocBuilderDev commented Jul 26, 2023

The documentation is not available anymore as the PR was closed or merged.

@patrickvonplaten
Copy link
Contributor

Can we add a test here as well? :-)

@patrickvonplaten
Copy link
Contributor

Thanks for adding the test :-)

@patrickvonplaten patrickvonplaten merged commit 5fd3dca into main Jul 27, 2023
patrickvonplaten pushed a commit that referenced this pull request Jul 27, 2023
…4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
keturn added a commit to invoke-ai/InvokeAI that referenced this pull request Jul 28, 2023
Fixed upstream by huggingface/diffusers#4278 before I even got to reporting it — thank you!
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
…uggingface#4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
…uggingface#4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
orpatashnik pushed a commit to orpatashnik/diffusers that referenced this pull request Aug 1, 2023
…uggingface#4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
@kashif kashif deleted the prompt-batch-size branch September 13, 2023 13:40
yoonseokjin pushed a commit to yoonseokjin/diffusers that referenced this pull request Dec 25, 2023
…uggingface#4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
AmericanPresidentJimmyCarter pushed a commit to AmericanPresidentJimmyCarter/diffusers that referenced this pull request Apr 26, 2024
…uggingface#4278)

* fix batch_size

* add test

---------

Co-authored-by: yiyixuxu <yixu310@gmail,com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants