404 Error when loading pretrained model, after finetuning
Author: nikky4D
Pull request: no

I'm trying to load up a finetuned T5 model I've saved but I keep getting a 404 error.

I have my model saved in the same directory as my jupyter notebook, at ```textgen_models/textgen_model_shuffle_e10/```
It contains a config.json, and a pytorch_model.bin
"""
```
model_path = Path("textgen_models/textgen_model_shuffle_e10/")
mdl = T5ForConditionalGeneration.from_pretrained(model_path)
```
"""

I am getting the following 404 error, which tells me I am not specifying the path to the model properly, though I'm not sure what I'm doing incorrectly. Can someone help?

"""
```
404 Client Error: Not Found for url: https://huggingface.co/textgen_models%5Ctextgen_model_shuffle_e10/resolve/main/config.json
---------------------------------------------------------------------------
HTTPError                                 Traceback (most recent call last)
~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\configuration_utils.py in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
    511             # Load from URL or cache if already cached
--> 512             resolved_config_file = cached_path(
    513                 config_file,

~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\file_utils.py in cached_path(url_or_filename, cache_dir, force_download, proxies, resume_download, user_agent, extract_compressed_file, force_extract, use_auth_token, local_files_only)
   1362         # URL, so get it from the cache (downloading if necessary)
-> 1363         output_path = get_from_cache(
   1364             url_or_filename,

~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\file_utils.py in get_from_cache(url, cache_dir, force_download, proxies, etag_timeout, resume_download, user_agent, use_auth_token, local_files_only)
   1533             r = requests.head(url, headers=headers, allow_redirects=False, proxies=proxies, timeout=etag_timeout)
-> 1534             r.raise_for_status()
   1535             etag = r.headers.get("X-Linked-Etag") or r.headers.get("ETag")

~\anaconda3\envs\imagesTemporal\lib\site-packages\requests\models.py in raise_for_status(self)
    952         if http_error_msg:
--> 953             raise HTTPError(http_error_msg, response=self)
    954 

HTTPError: 404 Client Error: Not Found for url: https://huggingface.co/textgen_models%5Ctextgen_model_shuffle_e10/resolve/main/config.json

During handling of the above exception, another exception occurred:

OSError                                   Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_11592/172074313.py in <module>
      1 model_path = Path("textgen_models/textgen_model_shuffle_e10/")
----> 2 mdl = T5ForConditionalGeneration.from_pretrained(pretrained_model_name_or_path = model_path)

~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\modeling_utils.py in from_pretrained(cls, pretrained_model_name_or_path, *model_args, **kwargs)
   1181         if not isinstance(config, PretrainedConfig):
   1182             config_path = config if config is not None else pretrained_model_name_or_path
-> 1183             config, model_kwargs = cls.config_class.from_pretrained(
   1184                 config_path,
   1185                 *model_args,

~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\configuration_utils.py in from_pretrained(cls, pretrained_model_name_or_path, **kwargs)
    453 
    454         """
--> 455         config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
    456         if "model_type" in config_dict and hasattr(cls, "model_type") and config_dict["model_type"] != cls.model_type:
    457             logger.warn(

~\anaconda3\envs\imagesTemporal\lib\site-packages\transformers\configuration_utils.py in get_config_dict(cls, pretrained_model_name_or_path, **kwargs)
    530                 f"- or '{pretrained_model_name_or_path}' is the correct path to a directory containing a {CONFIG_NAME} file\n\n"
    531             )
--> 532             raise EnvironmentError(msg)
    533 
    534         except json.JSONDecodeError:

OSError: Can't load config for 'textgen_models\textgen_model_shuffle_e10'. Make sure that:

- 'textgen_models\textgen_model_shuffle_e10' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'textgen_models\textgen_model_shuffle_e10' is the correct path to a directory containing a config.json file

```
"""


Comments:
How did you save your model? Was it with the `same_pretrained` method? The error says it can't locate the `config.json` associated to the model, so double check you have that file in the folder you are loading from.

Thank you for the pointer. I was able to solve it with a full path input, so I think I was not specifying the relative path correctly.