Skip to content

Add Idefics2/3 and SmolVLM Fast image processors + improvements for fast image processors #38157

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

Conversation

yonigozlan
Copy link
Member

@yonigozlan yonigozlan commented May 15, 2025

What does this PR do?

Several things added to this PR:

  • Idefics2/3 + smolvlm fast image processors. Cc @andimarafioti :)
  • Improvements in the base fast image processors to better handle nested images
    • group_images_by_shape and reorder_images can now handle nested images, flattening them for processing then rebuilding the original nesting
  • Improvements/uniformization to fast image processor tests (use torch.testing.assertclose)
  • Disable grouping by default when processing on cpu, enable it on gpu for all processors. As the benchmarks below suggests, it seems that grouping images when processing on cpu is almost always slower, but almost always faster on gpu. This seems to be the case for other image processors as well.

Thanks a lot to @sushmanthreddy and @rootonchair for their PRs on idefics2/3 image processors (here and here)

Here are the results for idefics2 and idefics3/smolvlm:

Idefics2 time per images:

time_per_image_all_configs

With different image sizes:

time_per_image_all_configs time_per_image_all_configs
time_per_image_all_configs time_per_image_all_configs

Idefics2 speedups:

speedup_vs_slow

With different image sizes:

speedup_vs_slow speedup_vs_slow
speedup_vs_slow speedup_vs_slow

Idefics3/SmolVLM time per images:

time_per_image_all_configs

With different image sizes:

time_per_image_all_configs time_per_image_all_configs
time_per_image_all_configs time_per_image_all_configs

Idefics3/SmolVLM speedups:

speedup_vs_slow

With different image sizes:

speedup_vs_slow speedup_vs_slow
speedup_vs_slow speedup_vs_slow

Copy link
Contributor

Hi 👋, thank you for opening this pull request! The pull request is converted to draft by default. The CI will be paused while the PR is in draft mode. When it is ready for review, please click the Ready for review button (at the bottom of the PR page). This will assign reviewers and trigger CI.

@github-actions github-actions bot marked this pull request as draft May 15, 2025 15:17
@yonigozlan yonigozlan marked this pull request as ready for review May 15, 2025 15:20
@yonigozlan yonigozlan requested a review from ArthurZucker May 15, 2025 15:41
@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.

@yonigozlan yonigozlan force-pushed the improve-support-nested-fast-image-proc branch from c6f31c4 to cd404b7 Compare May 15, 2025 19:36
@yonigozlan yonigozlan mentioned this pull request May 15, 2025
5 tasks
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.

2 participants