I get OSError: ... is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models' for valid models
Author: ogkalu2
Pull request: no
Labels: name: bug

### System Info

OS: Windows 11
Python: Both 3.11.6 and 3.12.9
Pytorch: Both 2.2.0 and 2.6.0

### Who can help?

_No response_

### Information

- [x] The official example scripts
- [ ] My own modified scripts

### Tasks

- [x] An officially supported task in the `examples` folder (such as GLUE/SQuAD, ...)
- [ ] My own task or dataset (give details below)

### Reproduction

```
from transformers import OmDetTurboProcessor, OmDetTurboForObjectDetection
processor = OmDetTurboProcessor.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
model = OmDetTurboForObjectDetection.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
```

I can't reproduce this in colab so i figure it's my system but i can't figure out why. I get this trying to load any model. I also tried rt-detr and got similar errors

Full Traceback:
```
Traceback (most recent call last):
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\utils\_http.py", line 406, in hf_raise_for_status
    response.raise_for_status()
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\requests\models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/omlab/omdet-turbo-swin-tiny-hf/resolve/main/preprocessor_config.json

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\utils\hub.py", line 403, in cached_file
    resolved_file = hf_hub_download(
                    ^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 860, in hf_hub_download
    return _hf_hub_download_to_cache_dir(
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 967, in _hf_hub_download_to_cache_dir
    _raise_on_head_call_error(head_call_error, force_download, local_files_only)
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1482, in _raise_on_head_call_error
    raise head_call_error
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1374, in _get_metadata_or_catch_error
    metadata = get_hf_file_metadata(
               ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\utils\_validators.py", line 114, in _inner_fn
    return fn(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 1294, in get_hf_file_metadata
    r = _request_wrapper(
        ^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 278, in _request_wrapper
    response = _request_wrapper(
               ^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\file_download.py", line 302, in _request_wrapper
    hf_raise_for_status(response)
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\utils\_http.py", line 454, in hf_raise_for_status
    raise _format(RepositoryNotFoundError, message, response) from e
huggingface_hub.errors.RepositoryNotFoundError: 401 Client Error. (Request ID: Root=1-67a9034f-3221be180265fb393ff1b352;afb39851-99d5-491d-8d27-f58783b491da)

Repository Not Found for url: https://huggingface.co/omlab/omdet-turbo-swin-tiny-hf/resolve/main/preprocessor_config.json.
Please make sure you specified the correct `repo_id` and `repo_type`.
If you are trying to access a private or gated repo, make sure you are authenticated.
Invalid credentials in Authorization header

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "C:\Users\obkal\Desktop\cbtest\omdet\detect.py", line 5, in <module>
    processor = OmDetTurboProcessor.from_pretrained("omlab/omdet-turbo-swin-tiny-hf")
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\processing_utils.py", line 974, in from_pretrained
    args = cls._get_arguments_from_pretrained(pretrained_model_name_or_path, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\processing_utils.py", line 1020, in _get_arguments_from_pretrained
    args.append(attribute_class.from_pretrained(pretrained_model_name_or_path, **kwargs))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\image_processing_base.py", line 209, in from_pretrained
    image_processor_dict, kwargs = cls.get_image_processor_dict(pretrained_model_name_or_path, **kwargs)
                                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\image_processing_base.py", line 341, in get_image_processor_dict
    resolved_image_processor_file = cached_file(
                                    ^^^^^^^^^^^^
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\transformers\utils\hub.py", line 426, in cached_file
    raise EnvironmentError(
OSError: omlab/omdet-turbo-swin-tiny-hf is not a local folder and is not a valid model identifier listed on 'https://huggingface.co/models'
If this is a private repository, make sure to pass a token having permission to this repo either by logging in with `huggingface-cli login` or by passing `token=<your_token>`
```

Comments:
Hi @ogkalu2, the code works for me! My guess is the "Invalid credentials in Authorization header" line is a clue. This is not a private or gated model, so you shouldn't need a login, but try:

1) Updating transformers with `pip install --upgrade transformers`
2) Updating the Hub client with `pip install --upgrade huggingface_hub`

If those don't work, you can also try logging into the HF Hub and getting a token, then saving that token with `huggingface-cli login`. That should ensure you have CLI access to all repos that your account has permissions on.

Closing for now because I think this is an environment issue rather than a bug in `transformers`, but feel free to reopen if you think there's a real bug here!

Hi @ogkalu2 , notice that the first error:

Traceback (most recent call last):
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\huggingface_hub\utils\_http.py", line 406, in hf_raise_for_status
    response.raise_for_status()
  File "C:\Users\obkal\Desktop\cbtest\omdet\.venv\Lib\site-packages\requests\models.py", line 1024, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/omlab/omdet-turbo-swin-tiny-hf/resolve/main/preprocessor_config.json

I met the same error as well the whole day, and I found the reason is the expired token (thank you very much @Rocketknight1 for your reminding). After creating a new token (Permission: FINEGRAINED), I could access models and datasets nromally.

Input the cli order with your token:
`!huggingface-cli login --token <your token>`

@zihanzhao1022 @Rocketknight1 
Thanks. Deleting the token file resolved the issue

Deleting the token file (` ~/.cache/huggingface/token`)  resolved the issue for me too