KEMBAR78
[video processors] decode only sampled videos -> less RAM and faster processing by zucchini-nlp · Pull Request #39600 · huggingface/transformers · GitHub
Skip to content

Conversation

@zucchini-nlp
Copy link
Member

@zucchini-nlp zucchini-nlp commented Jul 23, 2025

What does this PR do?

This PR moves the video decoding code entirely into video processors, so that we can load only necessary video frames into memory. To be consistent with video processors, I also updated image processors to accept str in inputs and optionally load images.

The docs for video processors are also updated explaining how frames are sampled and what users need to do to turn it on/off. Note that we'll be using by default torchcodec and fallback to torchvision, and we won't support any arbitrary video decoders within video processor class. Otherwise we'd need to introduce more kwargs and handle differences between decoders, which bloats up the code even more

@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.

@zucchini-nlp zucchini-nlp requested a review from qubvel August 4, 2025 13:12
Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

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

Thanks for the PR, it should be a great improvement!

Copy link
Contributor

Choose a reason for hiding this comment

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

cc @yonigozlan for changes in this file

@zucchini-nlp
Copy link
Member Author

run-slow: aria, aya_vision, blip, bridgetower, chameleon, clip, colpali, deepseek_vl, deepseek_vl_hybrid, emu3, eomt, flava, gemma3, gemma3n, glm4v

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ['models/aria', 'models/aya_vision', 'models/blip', 'models/bridgetower', 'models/chameleon', 'models/clip', 'models/colpali', 'models/deepseek_vl', 'models/deepseek_vl_hybrid', 'models/emu3', 'models/eomt', 'models/flava', 'models/gemma3', 'models/gemma3n', 'models/glm4v']
quantizations: [] ...

@zucchini-nlp
Copy link
Member Author

@qubvel I merged the related PR and rebased main. Can you take another look?

Copy link
Contributor

@qubvel qubvel left a comment

Choose a reason for hiding this comment

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

Thanks! Great work

@zucchini-nlp
Copy link
Member Author

run-slow: aria, aya_vision, blip, bridgetower, chameleon, clip, colpali, deepseek_vl, deepseek_vl_hybrid, emu3, eomt, flava, gemma3, gemma3n, glm4v

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ['models/aria', 'models/aya_vision', 'models/blip', 'models/bridgetower', 'models/chameleon', 'models/clip', 'models/colpali', 'models/deepseek_vl', 'models/deepseek_vl_hybrid', 'models/emu3', 'models/eomt', 'models/flava', 'models/gemma3', 'models/gemma3n', 'models/glm4v']
quantizations: [] ...

@zucchini-nlp
Copy link
Member Author

run-slow: qwen2_vl, qwen2_5_vl, qwen2_5_omni, smolvlm, llava_onevision, llava_next_video, perception_lm

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ['models/llava_next_video', 'models/llava_onevision', 'models/perception_lm', 'models/qwen2_5_omni', 'models/qwen2_5_vl', 'models/qwen2_vl', 'models/smolvlm']
quantizations: [] ...

@zucchini-nlp
Copy link
Member Author

zucchini-nlp commented Aug 19, 2025

On no, new torch release doesn't work well with Bytes objects 😓 (fails only in CI, still figuring out why)

@zucchini-nlp
Copy link
Member Author

run-slow: qwen2_vl, qwen2_5_vl, qwen2_5_omni, smolvlm, llava_onevision, llava_next_video, perception_lm

1 similar comment
@zucchini-nlp
Copy link
Member Author

run-slow: qwen2_vl, qwen2_5_vl, qwen2_5_omni, smolvlm, llava_onevision, llava_next_video, perception_lm

@github-actions
Copy link
Contributor

This comment contains run-slow, running the specified jobs:

models: ['models/llava_next_video', 'models/llava_onevision', 'models/perception_lm', 'models/qwen2_5_omni', 'models/qwen2_5_vl', 'models/qwen2_vl', 'models/smolvlm']
quantizations: [] ...

@zucchini-nlp
Copy link
Member Author

The CI is impossible to pass 🙃

@zucchini-nlp
Copy link
Member Author

@bot /style

@github-actions
Copy link
Contributor

github-actions bot commented Aug 26, 2025

Style bot fixed some files and pushed the changes.

@github-actions
Copy link
Contributor

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

run-slow: aria, aya_vision, blip, bridgetower, chameleon, clip, colpali, deepseek_vl, deepseek_vl_hybrid, emu3, eomt, flava, gemma3, gemma3n, glm4v

@zucchini-nlp zucchini-nlp merged commit f690a2a into huggingface:main Aug 26, 2025
24 checks passed
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