Skip to content

Fix AutoImageProcessor.from_pretrained failing with URL input#44838

Open
xr843 wants to merge 1 commit intohuggingface:mainfrom
xr843:fix/44821-image-processor-url
Open

Fix AutoImageProcessor.from_pretrained failing with URL input#44838
xr843 wants to merge 1 commit intohuggingface:mainfrom
xr843:fix/44821-image-processor-url

Conversation

@xr843
Copy link

@xr843 xr843 commented Mar 18, 2026

Summary

  • Fixes Unable to load AutoImageProcessor from URL #44821AutoImageProcessor.from_pretrained fails with OSError: Repo id must be in the form 'repo_name' or 'namespace/repo_name' when given a URL
  • The URL handling branch (is_remote_url check) in get_image_processor_dict was accidentally removed during the v5 cleanup
  • Restores URL support by adding an elif branch that detects HTTP(S) URLs, downloads the JSON content directly, and writes it to a temp file for parsing
  • Adds a unit test with mocked HTTP to verify URL-based loading works

Test plan

  • New test test_image_processor_from_pretrained_url passes — verifies that a mocked URL returns a valid ViTImageProcessor
  • Existing ImageProcessorUtilTester tests still pass
  • Manually test with transformers.AutoImageProcessor.from_pretrained("https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json")

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) noreply@anthropic.com

…ingface#44821)

Restore URL handling in `get_image_processor_dict` that was accidentally
removed. When a URL is passed as pretrained_model_name_or_path, the
method now downloads the JSON file directly instead of passing the URL
to `cached_file()` which expects a repo ID.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

Unable to load AutoImageProcessor from URL

1 participant