Skip to content

Add fast image processor Janus, Deepseek VL, Deepseek VL hybrid #39739

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 2 commits into
base: main
Choose a base branch
from

Conversation

yonigozlan
Copy link
Member

As the title says.
Cc @zucchini-nlp as I think you reviewed these models?
Also it would be great to have fast image processors on release for the newest models, don't hesitate to ping me on the PRs, happy to help!

@HuggingFaceDocBuilderDev

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.

Copy link
Contributor

[For maintainers] Suggested jobs to run (before merge)

run-slow: auto, deepseek_vl, deepseek_vl_hybrid, janus

@yonigozlan yonigozlan requested a review from Cyrilvallez July 29, 2025 14:47
Copy link
Member

@zucchini-nlp zucchini-nlp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great thanks! Yep, indeed, adding fast from the model release is better. I will nudge users to do so

Comment on lines +747 to +754
if kwargs.get("image_mean", None) is None:
background_color = (127, 127, 127)
else:
background_color = tuple([int(x * 255) for x in kwargs.get("image_mean")])
if kwargs.get("high_res_image_mean", None) is None:
background_color = (127, 127, 127)
else:
background_color = tuple([int(x * 255) for x in kwargs.get("high_res_image_mean")])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see it is copied from "slow" processor but it looks weird. Ig this was meant to use image_mean and if not high_res_image_mean. Can we prettify a bit here for readbility?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes I meant to ask you, not sure what the original code intended to do in the slow processor. I copied it anyway for consistency, but it doesn't really make sense, because here it will always take the value depending on high_res_image_mean. Maybe it would make more sense to have two different background colors?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The values for high res and low res are identical, so that's why we didn't see issues prob. Having two values makes sense, even if it is the same value

for shape, stacked_high_res_padded_images in high_res_padded_images.items():
if do_resize:
stacked_images = self.resize(
image=stacked_high_res_padded_images, size=size, min_size=min_size, interpolation=interpolation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, in the slow processors for simple pixel_values we don't resize padded high-res images but the original PIL images. Can you verify this is correct?

Copy link
Member Author

@yonigozlan yonigozlan Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually struggled to get the equivalence tests to pass because of that, but it looks like we do resize from the resized (and padded as padding is done in resize in the slow processor) high-res-images in the slow image processor:

image = self.resize(
image=high_res_image, size=size_dict, resample=resample, input_data_format=input_data_format
)

Equivalence tests pass like this, but didn't pass when resizing from original PIL image

Happy to change both slow and fast image processors if that's not intended, but that will be a breaking change

Copy link
Member

@zucchini-nlp zucchini-nlp Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh right, the naming is same lol. Ig that's intended then, because the converted model passes equivalence tests. It just looks weird

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