Celestial-Bai / INHERIT

8 stars 3 forks source link

requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url #5

Closed Sanrrone closed 1 year ago

Sanrrone commented 1 year ago

Dears, I tried to run the test but I cannot figure out the error:

python3 IHT_predict.py --sequence ../test_phage.fasta --withpretrain True --model INHERIT.py --out test_out.txt
2023-02-28 17:17:57.719995: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
401 Client Error: Unauthorized for url: https://huggingface.co/bac_pretrained_model/resolve/main/config.json
Traceback (most recent call last):
  File "/data/opt/Software/INHERIT/INHERIT/transformers/configuration_utils.py", line 484, in get_config_dict
    resolved_config_file = cached_path(
  File "/data/opt/Software/INHERIT/INHERIT/transformers/file_utils.py", line 1280, in cached_path
    output_path = get_from_cache(
  File "/data/opt/Software/INHERIT/INHERIT/transformers/file_utils.py", line 1451, in get_from_cache
    r.raise_for_status()
  File "/data/opt/mambaforge/envs/inherit/lib/python3.9/site-packages/requests/models.py", line 1021, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: https://huggingface.co/bac_pretrained_model/resolve/main/config.json

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/data/opt/Software/INHERIT/INHERIT/IHT_predict.py", line 74, in <module>
    bertmodel = Baseline_IHT(freeze_bert=True, config=config, bac_bert_dir=BAC_PTRMODEL, pha_bert_dir=PHA_PTRMODEL)
  File "/data/opt/Software/INHERIT/INHERIT/INHERITModels.py", line 64, in __init__
    self.bacbert = BertForSequenceClassification.from_pretrained(bac_bert_dir)
  File "/data/opt/Software/INHERIT/INHERIT/transformers/modeling_utils.py", line 1067, in from_pretrained
    config, model_kwargs = cls.config_class.from_pretrained(
  File "/data/opt/Software/INHERIT/INHERIT/transformers/configuration_utils.py", line 427, in from_pretrained
    config_dict, kwargs = cls.get_config_dict(pretrained_model_name_or_path, **kwargs)
  File "/data/opt/Software/INHERIT/INHERIT/transformers/configuration_utils.py", line 504, in get_config_dict
    raise EnvironmentError(msg)
OSError: Can't load config for 'bac_pretrained_model'. Make sure that:

- 'bac_pretrained_model' is a correct model identifier listed on 'https://huggingface.co/models'

- or 'bac_pretrained_model' is the correct path to a directory containing a config.json file

What should I do?

thanks in advance!

Celestial-Bai commented 1 year ago

Hi Sanrrone,

To solve this issue, just change the paths of pre-trained models to the paths where they are in your PC.

Sanrrone commented 1 year ago

Hi, Just one less trivial question, what is the file I have to modify?

Celestial-Bai commented 1 year ago

Hi Sanrrone,

Glad to hear your questions. In your example, in bertmodel = Baseline_IHT(freeze_bert=True, config=config, bac_bert_dir=BAC_PTRMODEL, pha_bert_dir=PHA_PTRMODEL) (you can see it in the traceback), BAC_PTRMODEL and PHA_PTRMODEL is the one you should modified. Just change to your own local paths in IHT_config.py.