fix: allow AutoImageProcessor to load from URL#44826
Closed
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
Closed
fix: allow AutoImageProcessor to load from URL#44826BillionClaw wants to merge 1 commit intohuggingface:mainfrom
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
Conversation
Fixes huggingface#44821 This fix allows AutoImageProcessor.from_pretrained() to accept URLs directly, not just local file paths or repo IDs. The fix adds URL detection and loading support in both image_processing_base.py and configuration_utils.py.
Contributor
|
View the CircleCI Test Summary for this PR: https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44826&sha=bfc193 |
Member
|
lmao @censujiang |
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 #44821
This PR fixes the issue where
AutoImageProcessor.from_pretrained()was unable to load from a URL (e.g.,https://huggingface.co/.../raw/main/config.json).The bug was introduced in transformers>=5.3.0. Prior versions (e.g., 4.57.6) supported loading from URLs.
Changes
_is_url()helper function to detect URLs usingurllib.parse.urlparse_load_json_from_file_or_url()helper to load JSON from both local files and URLsImageProcessingMixin.get_image_processor_dict()to handle URLsPreTrainedConfig._get_config_dict()to handle URLsTesting
Tested with the example from the issue:
Also verified that local file paths continue to work correctly.