[英]unable to load NER pipeline with nlp.from_disk()
我正在嘗試將預先訓練的管道加載到我的代碼中,如下所示:
nlp = de_core_news_sm.load()
nlp = nlp.from_disk('./TRAINED/Background/')
但我收到一個 versos 錯誤說:
ValueError Traceback (most recent call last)
<ipython-input-4-1f41fefa6daa> in <module>
1 nlp = de_core_news_sm.load()
----> 2 nlp = nlp.from_disk('./TRAINED/Background/')
3 print(nlp)
/opt/anaconda3/lib/python3.8/site-packages/spacy/language.py in from_disk(self, path, exclude, disable)
972 # Convert to list here in case exclude is (default) tuple
973 exclude = list(exclude) + ["vocab"]
--> 974 util.from_disk(path, deserializers, exclude)
975 self._path = path
976 return self
/opt/anaconda3/lib/python3.8/site-packages/spacy/util.py in from_disk(path, readers, exclude)
688 # Split to support file names like meta.json
689 if key.split(".")[0] not in exclude:
--> 690 reader(path / key)
691 return path
692
/opt/anaconda3/lib/python3.8/site-packages/spacy/language.py in deserialize_vocab(path)
948 def deserialize_vocab(path):
949 if path.exists():
--> 950 self.vocab.from_disk(path)
951 _fix_pretrained_vectors_name(self)
952
vocab.pyx in spacy.vocab.Vocab.from_disk()
strings.pyx in spacy.strings.StringStore.from_disk()
/opt/anaconda3/lib/python3.8/site-packages/srsly/_json_api.py in read_json(location)
48 data = sys.stdin.read()
49 return ujson.loads(data)
---> 50 file_path = force_path(location)
51 with file_path.open("r", encoding="utf8") as f:
52 return ujson.load(f)
/opt/anaconda3/lib/python3.8/site-packages/srsly/util.py in force_path(location, require_exists)
19 location = Path(location)
20 if require_exists and not location.exists():
---> 21 raise ValueError("Can't read file: {}".format(location))
22 return location
23
ValueError: Can't read file: TRAINED/Background/vocab/strings.json
如果我在 macOS 上打開 Vocab 文件夾,則沒有 string.json 文件。 只是幾個 exec 文件。 我該怎么做才能正確讀取模型?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.