{{ message }}
Guard against a None video processor class when the backend is unavailable - #48557
Open
caiotheodoro wants to merge 1 commit into
Open
Guard against a None video processor class when the backend is unavailable#48557caiotheodoro wants to merge 1 commit into
caiotheodoro wants to merge 1 commit into
Conversation
…lable Without torchvision every VIDEO_PROCESSOR_MAPPING value is None while the config type is still a key, so `(video_processor_class or VIDEO_PROCESSOR_MAPPING[type(config)]).__module__` raised AttributeError for models whose video processor cannot be inferred, such as InternVL and InstructBLIP. That happens before the is_torchvision_available() check further down, so the informative error added in huggingface#44125 was never reached. Mirror image_processing_auto.py: guard the None and compute explicit_local_code only inside `if has_remote_code:`, the only place it is used.
caiotheodoro
force-pushed
the
fix/video-processor-none-guard
branch
from
September 6, 2026 03:04
3f40c01 to
5eef47b
Compare
Contributor
Contributor
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.

Fixes #48556
AutoProcessor.from_pretrained("OpenGVLab/InternVL3-1B-hf")without torchvision installed raisesAttributeError: 'NoneType' object has no attribute '__module__'atvideo_processing_auto.py:363, instead of the "requires torchvision" error added in #44125.has_local_codeis true when the config type is a key inVIDEO_PROCESSOR_MAPPING, but without torchvision every value in that mapping isNone. For InternVLvideo_processor_classis alsoNone— its image processor isGotOCRImageProcessorand noGotOCRVideoProcessorexists to infer from, which line 330 already handles — so(None or None).__module__raises.Salesforce/instructblip-vicuna-7bfails the same way, and InstructBLIP is image-only.This mirrors
image_processing_auto.py:655-664, which guards theNoneand computesexplicit_local_codeonly insideif has_remote_code:— the sole place it is used.After the change both models reach the intended error:
The test mirrors
test_unavailable_backend_error_mentions_missing_dependencyintests/models/auto/test_image_processing_auto.py. It usespatch.dict(VIDEO_PROCESSOR_MAPPING._extra_content, ...)to force theNonevalue while torchvision is installed in CI; happy to change that if you prefer a different seam.Differentiation from existing PRs
#44125 added the torchvision message at the end of this function but did not guard this earlier path. #45045 fixed a spurious torchvision requirement on PIL-backend image processors, a different code path. No open PR touches
explicit_local_codeinvideo_processing_auto.py.Tests
Reproduced on transformers 5.16.1 and
main@ c93057d, Python 3.11.15, macOS arm64, torchvision not installed.AI usage disclosure
Per CONTRIBUTING: this change was made with AI assistance. I hit the defect while loading a Qwen VL processor for a fine-tuning run on a machine without torchvision.