Skip to content
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

prepare_image in Kandinsky pipelines doesn't support torch.Tensor #11060

Open
dk-hong opened this issue Mar 14, 2025 · 1 comment · May be fixed by #11080
Open

prepare_image in Kandinsky pipelines doesn't support torch.Tensor #11060

dk-hong opened this issue Mar 14, 2025 · 1 comment · May be fixed by #11080
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@dk-hong
Copy link

dk-hong commented Mar 14, 2025

Hi, I want to report a bug in Kandinsky pipelines.

if not isinstance(image, list):
image = [image]
if not all(isinstance(i, (PIL.Image.Image, torch.Tensor)) for i in image):
raise ValueError(
f"Input is in incorrect format: {[type(i) for i in image]}. Currently, we only support PIL image and pytorch tensor"
)
image = torch.cat([prepare_image(i, width, height) for i in image], dim=0)

According to the above contents, elements in image can be either PIL.Image.Image or torch.Tensor.

def prepare_image(pil_image, w=512, h=512):
pil_image = pil_image.resize((w, h), resample=Image.BICUBIC, reducing_gap=1)
arr = np.array(pil_image.convert("RGB"))
arr = arr.astype(np.float32) / 127.5 - 1
arr = np.transpose(arr, [2, 0, 1])
image = torch.from_numpy(arr).unsqueeze(0)
return image

However, the prepare_image function is only for PIL.Image.Image, and does not support torch.Tensor.

Can you resolve this problem by implementing an image resize function for torch.Tensor?

@DN6 DN6 added good first issue Good for newcomers help wanted Extra attention is needed labels Mar 17, 2025
@DN6
Copy link
Collaborator

DN6 commented Mar 17, 2025

Hi @dk-hong I don't think we have the bandwidth to implement this at the moment. Opening it up to the community

@ishan-modi ishan-modi linked a pull request Mar 17, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants