HIT-SCIR / ltp

Language Technology Platform
http://ltp.ai
4.98k stars 1.04k forks source link

RuntimeError: wrong magic in header #689

Closed SingL3 closed 8 months ago

SingL3 commented 8 months ago
import torch
from ltp import LTP

# 使用感知机算法实现的分词、词性和命名实体识别,速度比较快,但是精度略低
ltp = LTP("/mnt/data/linjunpeng/search/ltp_legacy")
# cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "ner"]).to_tuple() # error: NER 需要 词性标注任务的结果
cws, pos, ner = ltp.pipeline(["他叫汤姆去拿外衣。"], tasks=["cws", "pos", "ner"]).to_tuple()  # to tuple 可以自动转换为元组格式
# 使用元组格式作为返回结果
print(ner)
Loading weights from local directory
Traceback (most recent call last):
  File "/mnt/home/frontend/ner/predict.py", line 132, in <module>
    ltp = LTP("/mnt/data/search/ltp_legacy")
  File "/mnt/data/conda/envs/frontend/lib/python3.10/site-packages/ltp/interface.py", line 137, in LTP
    return LTP_legacy._from_pretrained(
  File "/mnt/data/conda/envs/frontend/lib/python3.10/site-packages/ltp/legacy.py", line 170, in _from_pretrained
    ltp = cls(**model_files)
  File "/mnt/data/conda/envs/frontend/lib/python3.10/site-packages/ltp/legacy.py", line 15, in __init__
    self.cws_model = CWSModel.load(cws) if cws else None
RuntimeError: wrong magic in header