modelscope / FunASR

A Fundamental End-to-End Speech Recognition Toolkit and Open Source SOTA Pretrained Models, Supporting Speech Recognition, Voice Activity Detection, Text Post-processing etc.
https://www.funasr.com
Other
6.8k stars 720 forks source link

Docker执行demo报错:_pickle.UnpicklingError: invalid load key, 'v'. #579

Closed gOODiDEA2002 closed 1 year ago

gOODiDEA2002 commented 1 year ago

完整错误

#0 216.2 Traceback (most recent call last):
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/modelscope/utils/registry.py", line 212, in build_from_cfg
#0 216.2     return obj_cls(**args)
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/audio/asr_inference_pipeline.py", line 163, in __init__
#0 216.2     **kwargs,
#0 216.2   File "/FunASR/funasr/bin/asr_inference_launch.py", line 1640, in inference_launch
#0 216.2     return inference_paraformer(**kwargs)
#0 216.2   File "/FunASR/funasr/bin/asr_inference_launch.py", line 330, in inference_paraformer
#0 216.2     speech2text = Speech2TextParaformer(**speech2text_kwargs)
#0 216.2   File "/FunASR/funasr/bin/asr_infer.py", line 340, in __init__
#0 216.2     lm_train_config, lm_file, device
#0 216.2   File "/FunASR/funasr/tasks/abs_task.py", line 1964, in build_model_from_file
#0 216.2     model.load_state_dict(torch.load(model_file, map_location=device))
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/torch/serialization.py", line 713, in load
#0 216.2     return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/torch/serialization.py", line 920, in _legacy_load
#0 216.2     magic_number = pickle_module.load(f, **pickle_load_args)
#0 216.2 _pickle.UnpicklingError: invalid load key, 'v'.
#0 216.2
#0 216.2 During handling of the above exception, another exception occurred:
#0 216.2
#0 216.2 Traceback (most recent call last):
#0 216.2   File "/test-models.py", line 6, in <module>
#0 216.2     model='./speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch')
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 140, in pipeline
#0 216.2     return build_pipeline(cfg, task_name=task)
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/modelscope/pipelines/builder.py", line 57, in build_pipeline
#0 216.2     cfg, PIPELINES, group_key=task_name, default_args=default_args)
#0 216.2   File "/opt/conda/lib/python3.7/site-packages/modelscope/utils/registry.py", line 215, in build_from_cfg
#0 216.2     raise type(e)(f'{obj_cls.__name__}: {e}')
#0 216.2 _pickle.UnpicklingError: AutomaticSpeechRecognitionPipeline: invalid load key, 'v'.

重现步骤

下载:speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch

git lfs clone https://www.modelscope.cn/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch.git

下载:model.pb并替换speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch目录中同名文件

下载地址:https://www.modelscope.cn/api/v1/models/damo/speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/repo?Revision=v1.2.1&FilePath=model.pb

dockerfile


FROM registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-py37-torch1.11.0-tf1.15.5-1.6.0

COPY speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch ./speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch

#升级modelscope指令:
RUN pip install -U modelscope -f https://modelscope.oss-cn-beijing.aliyuncs.com/releases/repo.html -i https://mirror.sjtu.edu.cn/pypi/web/simple

#升级funasr指令:
RUN git clone https://github.com/alibaba/FunASR.git && cd FunASR
RUN pip install -e ./FunASR

#RUN pip install -U funasr_onnx -i https://mirror.sjtu.edu.cn/pypi/web/simple

ADD test-models.py /

RUN python /test-models.py && \
    rm -rf /test-models.py

test-models.py

from modelscope.pipelines import pipeline
from modelscope.utils.constant import Tasks

inference_pipeline = pipeline(
    task=Tasks.auto_speech_recognition,
    model='./speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch')

rec_result = inference_pipeline(audio_in='./speech_paraformer-large_asr_nat-zh-cn-16k-common-vocab8404-pytorch/example/asr_example.wav')
print(rec_result)

执行:docker build -t funasr .

LauraGPT commented 1 year ago

OS: [e.g. linux] Python/C++ Version: Package Version:pytorch、torchaudio、modelscope、funasr version(pip list) Model: Command: Details: Error log:

gOODiDEA2002 commented 1 year ago

OS: Mac Os 13.4 Docker: registry.cn-hangzhou.aliyuncs.com/modelscope-repo/modelscope:ubuntu20.04-py37-torch1.11.0-tf1.15.5-1.6.0