Skip to content

fix: allow AutoImageProcessor to load from URL#44826

Closed
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
BillionClaw:clawoss/fix/imageprocessor-url-1773835698
Closed

fix: allow AutoImageProcessor to load from URL#44826
BillionClaw wants to merge 1 commit intohuggingface:mainfrom
BillionClaw:clawoss/fix/imageprocessor-url-1773835698

Conversation

@BillionClaw
Copy link
Copy Markdown

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

  • Added _is_url() helper function to detect URLs using urllib.parse.urlparse
  • Added _load_json_from_file_or_url() helper to load JSON from both local files and URLs
  • Modified ImageProcessingMixin.get_image_processor_dict() to handle URLs
  • Modified PreTrainedConfig._get_config_dict() to handle URLs

Testing

Tested with the example from the issue:

import transformers
url = 'https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json'
processor = transformers.AutoImageProcessor.from_pretrained(url)  # Now works

Also verified that local file paths continue to work correctly.

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.
@github-actions
Copy link
Copy Markdown
Contributor

View the CircleCI Test Summary for this PR:

https://huggingface.co/spaces/transformers-community/circle-ci-viz?pr=44826&sha=bfc193

@censujiang
Copy link
Copy Markdown

telegram-cloud-photo-size-5-6185977277322038803-y

@Rocketknight1
Copy link
Copy Markdown
Member

lmao @censujiang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unable to load AutoImageProcessor from URL

3 participants