Fix: add None check for extractors in video_processor_class_from_name#42774
Open
Blaizzy wants to merge 1 commit intohuggingface:mainfrom
Open
Fix: add None check for extractors in video_processor_class_from_name#42774Blaizzy wants to merge 1 commit intohuggingface:mainfrom
Blaizzy wants to merge 1 commit intohuggingface:mainfrom
Conversation
Contributor
|
[For maintainers] Suggested jobs to run (before merge) run-slow: auto |
Member
|
Makes sense to me but cc @zucchini-nlp @molbap @yonigozlan to check if this is the right thing to do when we don't have |
| def video_processor_class_from_name(class_name: str): | ||
| for module_name, extractors in VIDEO_PROCESSOR_MAPPING_NAMES.items(): | ||
| if class_name in extractors: | ||
| if extractors is not None and class_name in extractors: |
Member
There was a problem hiding this comment.
seems like this must have been an equal check class_name == extractor because in video mapping we have only one class per model. I doubt that class_name in extractor is needed
This was referenced Apr 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Here's a PR message for the fix:
What does this PR do?
Fixes
TypeError: argument of type 'NoneType' is not iterablewhen loading VLM processors withouttorchvisioninstalled.The Problem
When
torchvisionis not available, theVIDEO_PROCESSOR_MAPPING_NAMESdictionary values are set toNone(lines 84-87 invideo_processing_auto.py). However,video_processor_class_from_name()attempts to checkif class_name in extractorswithout first verifying thatextractorsis notNone, causing the TypeError.The Fix
Added a
Nonecheck before the membership test:This allows the function to safely skip entries where the video processor class is
None(i.e., whentorchvisionis unavailable) and continue searching through other mappings or returnNonegracefully pointing out the root cause of the error.Traceback
Before fix:
After fix:
Reproduction