-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
[Core] is_cosxl_edit
arg in SDXL ip2p.
#7650
Conversation
Co-authored-by: Yiyi Xu <yixu310@gmail.com>
The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update. |
@DN6 your comments have been addressed. |
Failing test is quite unrelated. |
Here's testing code: import torch
from diffusers import StableDiffusionXLInstructPix2PixPipeline, EDMEulerScheduler
from diffusers.utils import load_image
import numpy as np
import math
def set_timesteps_patched(self, num_inference_steps: int, device = None):
self.num_inference_steps = num_inference_steps
ramp = np.linspace(0, 1, self.num_inference_steps)
sigmas = torch.linspace(math.log(self.config.sigma_min), math.log(self.config.sigma_max), len(ramp)).exp().flip(0)
sigmas = (sigmas).to(dtype=torch.float32, device=device)
self.timesteps = self.precondition_noise(sigmas)
self.sigmas = torch.cat([sigmas, torch.zeros(1, device=sigmas.device)])
self._step_index = None
self._begin_index = None
self.sigmas = self.sigmas.to("cpu") # to avoid too much CPU/GPU communication
inst_file = "https://huggingface.co/stabilityai/cosxl/blob/main/cosxl_edit.safetensors"
pipe = StableDiffusionXLInstructPix2PixPipeline.from_single_file(
inst_file, num_in_channels=8, is_cosxl_edit=True
).to("cuda")
# This won't be needed after https://github.com/huggingface/diffusers/pull/7649
EDMEulerScheduler.set_timesteps = set_timesteps_patched
pipe.scheduler = EDMEulerScheduler(sigma_min=0.002, sigma_max=120.0, sigma_data=1.0, prediction_type="v_prediction")
resolution = 1024
image = load_image(
"https://hf.co/datasets/diffusers/diffusers-images-docs/resolve/main/mountain.png"
).resize((resolution, resolution))
edit_instruction = "Turn sky into a cloudy one"
edited_image = pipe(
prompt=edit_instruction,
image=image,
height=resolution,
width=resolution,
num_inference_steps=20,
).images[0]
edited_image.save("edited_image.png") ^ matches what Yiyi got here: #7621 (comment). |
Created an issue for the installation failure here: astral-sh/uv#3031. I will submit a quick PR replacing the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍🏽. The failing test looks unrelated.
* is_cosxl_edit arg in SDXL ip2p. * Empty-Commit Co-authored-by: Yiyi Xu <yixu310@gmail.com> * doc * remove redundant logic. * reflect drhuv's comments. --------- Co-authored-by: Yiyi Xu <yixu310@gmail.com> Co-authored-by: Dhruv Nair <dhruv.nair@gmail.com>
What does this PR do?
As found out by @yiyixuxu here:
#7621 (comment)
Related to #7621.
Cc: @apolinario for awareness.