Unable to load pre-trained model
See original GitHub issueHi
I’m trying to use a pre-trained model for NER,and once the model got downloaded, I’m getting the below issue.
from deeppavlov import configs, build_model
ner_model = build_model(configs.ner.ner_ontonotes_bert, download=True)
2020-02-18 17:45:34.88 ERROR in 'deeppavlov.core.common.params'['params'] at line 112: Exception in <class 'deeppavlov.models.preprocessors.bert_preprocessor.BertNerPreprocessor'>
Traceback (most recent call last):
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\deeppavlov\core\common\params.py", line 106, in from_params
component = obj(**dict(config_params, **kwargs))
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\deeppavlov\models\preprocessors\bert_preprocessor.py", line 119, in __init__
do_lower_case=do_lower_case)
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\bert_dp\tokenization.py", line 165, in __init__
self.vocab = load_vocab(vocab_file)
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\bert_dp\tokenization.py", line 127, in load_vocab
token = convert_to_unicode(reader.readline())
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 178, in readline
self._preread_check()
File "C:\Users\mchandra\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py", line 84, in _preread_check
compat.as_bytes(self.__name), 1024 * 512)
tensorflow.python.framework.errors_impl.NotFoundError: NewRandomAccessFile failed to Create/Open: C:\Users\mchandra\.deeppavlov\downloads\bert_models\cased_L-12_H-768_A-12\vocab.txt : The system cannot find the file specified.
; No such file or directory
---------------------------------------------------------------------------
NotFoundError Traceback (most recent call last)
<ipython-input-5-f2cfbde6d24a> in <module>
1 from deeppavlov import configs, build_model
2
----> 3 ner_model = build_model(configs.ner.ner_ontonotes_bert, download=False)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\deeppavlov\core\commands\infer.py in build_model(config, mode, load_trained, download, serialized)
59 component_serialized = None
60
---> 61 component = from_params(component_config, mode=mode, serialized=component_serialized)
62
63 if 'id' in component_config:
~\AppData\Local\Continuum\anaconda3\lib\site-packages\deeppavlov\core\common\params.py in from_params(params, mode, serialized, **kwargs)
104 kwargs['mode'] = mode
105
--> 106 component = obj(**dict(config_params, **kwargs))
107 try:
108 _refs[config_params['id']] = component
~\AppData\Local\Continuum\anaconda3\lib\site-packages\deeppavlov\models\preprocessors\bert_preprocessor.py in __init__(self, vocab_file, do_lower_case, max_seq_length, max_subword_length, token_masking_prob, provide_subword_tags, subword_mask_mode, **kwargs)
117 vocab_file = str(expand_path(vocab_file))
118 self.tokenizer = FullTokenizer(vocab_file=vocab_file,
--> 119 do_lower_case=do_lower_case)
120 self.token_masking_prob = token_masking_prob
121
~\AppData\Local\Continuum\anaconda3\lib\site-packages\bert_dp\tokenization.py in __init__(self, vocab_file, do_lower_case)
163
164 def __init__(self, vocab_file, do_lower_case=True):
--> 165 self.vocab = load_vocab(vocab_file)
166 self.inv_vocab = {v: k for k, v in self.vocab.items()}
167 self.basic_tokenizer = BasicTokenizer(do_lower_case=do_lower_case)
~\AppData\Local\Continuum\anaconda3\lib\site-packages\bert_dp\tokenization.py in load_vocab(vocab_file)
125 with tf.gfile.GFile(vocab_file, "r") as reader:
126 while True:
--> 127 token = convert_to_unicode(reader.readline())
128 if not token:
129 break
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py in readline(self)
176 def readline(self):
177 r"""Reads the next line from the file. Leaves the '\n' at the end."""
--> 178 self._preread_check()
179 return self._prepare_value(self._read_buf.ReadLineAsString())
180
~\AppData\Local\Continuum\anaconda3\lib\site-packages\tensorflow\python\lib\io\file_io.py in _preread_check(self)
82 "File isn't open for reading")
83 self._read_buf = pywrap_tensorflow.CreateBufferedInputStream(
---> 84 compat.as_bytes(self.__name), 1024 * 512)
85
86 def _prewrite_check(self):
NotFoundError: NewRandomAccessFile failed to Create/Open: C:\Users\mchandra\.deeppavlov\downloads\bert_models\cased_L-12_H-768_A-12\vocab.txt : The system cannot find the file specified.
; No such file or directory
Can you please let me the way of fixing this, I used ner_ontonotes as well but its working fine,have the problem with bert models.
Thanks in advance.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Can't load pretrained TrOCR model #16687 - GitHub
NielsRogge I get this error when I try to load a local TrOCR checkpoint. >>> processor = TrOCRProcessor.from_pretrained(".
Read more >Unable to load pre-trained model checkpoint with TensorFlow ...
DataLossError: Unable to open table file C:\Users\Pierre\Desktop\Adv-ML-Project\models\research\object_detection\test_data\checkpoint\ckpt-0.
Read more >OSError: Unable to load weights from pytorch checkpoint file
Hi, everyone. I need some help. I have been developing the Flask website that has embedded one of Transformer's fine-tuned models within it....
Read more >Unable to load pretrained weight into custom model in Pytorch ...
I want to retrain a custom model with my data. I can load the pretrained weights (.pth file) into the model in Pytorch...
Read more >Fix of "URL session failure" for loading pre-trained models
Fix of "URL session failure" for loading pre-trained models · Open whatever kernel you wanna load the pre-trained model from. · Then, open...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Not everything is downloaded. For some reason the
BERT
model is not. You can try and download it yourself: http://files.deeppavlov.ai/deeppavlov_data/bert/cased_L-12_H-768_A-12.zip And then extract the directory inC:\Users\mchandra\.deeppavlov\downloads\bert_models
Hi @RAVANv2, This is not an error message. It shows that you already have the required files and that their hashes match those of requested files on the server.