Skip to content

Fix AttributeError of VisualClozeProcessor #12121

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Justin900429
Copy link
Contributor

Summary

Fixes an AttributeError in VisualClozePipeline where the code attempted to access a non-existent height function on VisualClozeProcessor. The pipeline now calls the correct resizing utility (_resize_and_crop) during preprocessing.

if len(target_position) > 1 and sum(target_position) > 1:
new_w = resize_size[n_samples - 1][0] or 384
for i in range(len(processed_images)):
for j in range(len(processed_images[i])):
if processed_images[i][j] is not None:
new_h = int(processed_images[i][j].height * (new_w / processed_images[i][j].width))
new_w = int(new_w / 16) * 16
new_h = int(new_h / 16) * 16
processed_images[i][j] = self.height(processed_images[i][j], new_h, new_w)

This error occurs only when generating more than one image.

Reproduction

from diffusers import VisualClozePipeline
from PIL import Image
import torch

image_paths = [
    [
        Image.new("RGB", (384, 384), (0, 0, 0)),
        Image.new("RGB", (384, 384), (0, 0, 0)),
        Image.new("RGB", (384, 384), (0, 0, 0)),
    ],
    [
        Image.new("RGB", (384, 384), (0, 0, 0)),
        None,
        None,
    ],
]

task_prompt = "test"
content_prompt = None

pipe = VisualClozePipeline.from_pretrained(
    "VisualCloze/VisualClozePipeline-384", resolution=384, torch_dtype=torch.bfloat16
).to("cuda")

image_result = pipe(
    task_prompt=task_prompt,
    content_prompt=content_prompt,
    image=image_paths,
    upsampling_width=512,
    upsampling_height=512,
    upsampling_strength=0.0,
    guidance_scale=30,
    num_inference_steps=30,
    max_sequence_length=512,
    generator=torch.Generator("cuda").manual_seed(0),
).images[0]
  • Error:
AttributeError: 'VisualClozeProcessor' object has no attribute 'height'

@yiyixuxu @asomoza

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.

1 participant