-
Notifications
You must be signed in to change notification settings - Fork 6k
T2I-Adapters implementation does not support all official adapter models #6275
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
Comments
Could you confirm if an earlier version of diffusers was working fine? Cc: @williamberman |
nope, i tried few older versions of diffusers and its failing as well. but #3932 converted the original models to diffusers and added explicit tests for all those models - how did those tests pass? |
@williamberman could you check here? |
I am able to run "TencentARC/t2iadapter_canny_sd14v1" (didn't check for others) following the code provided in https://huggingface.co/TencentARC/t2iadapter_canny_sd14v1: Prepare condition: from diffusers.utils import load_image
from PIL import Image
import numpy as np
import cv2
image = load_image("https://huggingface.co/TencentARC/t2iadapter_canny_sd14v1/resolve/main/images/canny_input.png")
image = np.array(image)
low_threshold = 100
high_threshold = 200
image = cv2.Canny(image, low_threshold, high_threshold)
image = Image.fromarray(image) Load pipeline: import torch
from diffusers import StableDiffusionAdapterPipeline, T2IAdapter
adapter = T2IAdapter.from_pretrained("TencentARC/t2iadapter_canny_sd14v1").to(torch.float16)
pipe = StableDiffusionAdapterPipeline.from_pretrained(
"CompVis/stable-diffusion-v1-4",
torch_dtype=torch.float16,
adapter=adapter,
).to("cuda") Fire inference: out_image = pipe(
"a rabbit wearing glasses",
image=image,
generator=torch.manual_seed(0),
).images[0] I would suggest following the official code from the model cards closely and retrying and then coming back here. |
ok, i've narrowed it down - t2iadapter canny and sketch models are extremely sensitive to input and will cause an exception as i've described if input image is not correctly preprocessed. both your and my example work (nothing wrong with how pipeline is created), IF: image = load_image("https://huggingface.co/TencentARC/t2iadapter_canny_sd14v1/resolve/main/images/canny_input.png")
image = np.array(image)
image = cv2.Canny(image, threshold1=100, threshold2=200)
image = Image.fromarray(image) however, both your and my example will FAIL IF: image = Image.new('RGB', (512, 512), color='red') so what's the difference? one thing that comes to mind is that to confirm, just add image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB) to your example and it will FAIL. no other models exhibits this issue (only canny and sketch) - and it is a problem for production since how can we ensure that image is exactly what model expects? its users choice what to use as input and using wrong input causes an exception |
Problem is the following. When we do: image = load_image("https://huggingface.co/TencentARC/t2iadapter_canny_sd14v1/resolve/main/images/canny_input.png")
image = np.array(image)
print(image.shape)
image = cv2.Canny(image, threshold1=100, threshold2=200)
image = Image.fromarray(image)
print(np.array(image).shape) We get: (651, 628, 3)
(651, 628) It's a grayscale image. But with: image = Image.new('RGB', (512, 512), color='red')
print(np.array(image).shape) It evaluates to: (512, 512, 3) So, if you do: - image = Image.new('RGB', (512, 512), color='red')
+ image = Image.new('RGB', (512, 512), color='red')
+ image = image.convert('L') It works as expected. |
right. i was checking image = cv2.Canny(image, threshold1=100, threshold2=200)
image = Image.fromarray(image)
print(image) and it showed its still a bit messy since all other models (including controlnet canny and sketch models) work with |
Describe the bug
While testing adapters for SD15,
canny
andsketch
models are found to be incompatible with currentT2IAdapter
implementation in diffuserslooking at models itself, seems that those models actually have different configuration:
all working models have same shape:
while
canny
andsketch
models have different shape:Reproduction
Logs
System Info
torch==2.1.2+cu121 diffusers==0.25.0.dev0
Who can help?
@sayakpaul @yiyixuxu @DN6 @patrickvonplaten
The text was updated successfully, but these errors were encountered: