Skip to content

Unable to load AutoImageProcessor from URL #44821

@BSchilperoort

Description

@BSchilperoort

System Info

Versions

  • transformers version: 5.3.0
  • Platform: Linux-6.8.0-106-generic-x86_64-with-glibc2.39
  • Python version: 3.12.3
  • Huggingface_hub version: 1.7.1
  • Safetensors version: 0.7.0
  • Accelerate version: not installed
  • Accelerate config: not found
  • DeepSpeed version: not installed
  • PyTorch version (accelerator?): 2.10.0+cu128 (NA)

Bug

I am trying to load a config from URL, to instatiate the AutoImageProcessor. This worked before, but not anymore with new versions of transformers.

Bug starts occuring with transformers>=5.3.0. It worked with transformers==4.57.6

To reproduce;

import transformers

url = "https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json"
transformers.AutoImageProcessor.from_pretrained(url)  # fails on >=5.0, succeeds pre-5.0

local_file = "/path/to/config.json"  # download the file from the URL above
transformers.AutoImageProcessor.from_pretrained(local_file)  # succeeds on v4 and v5
traceback

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 514, in from_pretrained
    raise initial_exception
  File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/models/auto/image_processing_auto.py", line 501, in from_pretrained
    config_dict, _ = ImageProcessingMixin.get_image_processor_dict(
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/image_processing_base.py", line 282, in get_image_processor_dict
    resolved_processor_file = cached_file(
                              ^^^^^^^^^^^^
  File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/utils/hub.py", line 277, in cached_file
    file = cached_files(path_or_repo_id=path_or_repo_id, filenames=[filename], **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/bart/git/streetscapes/.venv/lib/python3.12/site-packages/transformers/utils/hub.py", line 469, in cached_files
    raise OSError(f"{e}") from e
OSError: Repo id must be in the form 'repo_name' or 'namespace/repo_name': 'https://huggingface.co/jinfengxie/BFMS_1014/raw/main/config.json'. Use `repo_type` argument if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions