"使用导出脚本如下:
from modelscope.models import Model
from modelscope.exporters import Exporter
model_id = 'damo/nlp_deberta_rex-uninlu_chinese-base'
cfg={""framework"":""pytorch"",""task"":""rex-uninlu"",""pipeline"":{""type"":""nlp_deberta_rex-uninlu_chinese-base-pipe""}}
model = Model.from_pretrained(model_id,revision='v1.2.1',cfg_dict=cfg)
output_files = Exporter.from_model(model).export_onnx(opset=13, output_dir='/root/nlp_structbert_sentence-similarity_chinese-base')
print(output_files)
错误如下 :
Traceback (most recent call last):
File ""export.py"", line 5, in
model = Model.from_pretrained(model_id,revision='v1.2.1',cfg_dict=cfg)
File ""/root/miniconda3/envs/nlp/lib/python3.8/site-packages/modelscope/models/base/base_model.py"", line 172, in from_pretrained
register_plugins_repo(cfg.safe_get('plugins'))
AttributeError: 'dict' object has no attribute 'safe_get'
modelscope版本:1.11.0 错误怎么解决?
这个模型的导出没有现成的代码,需要您参考现有的例子,如何在外部模型上使用导出功能。这里有目前可以直接使用的也可以参考
https://github.com/modelscope/modelscope/tree/master/modelscope/exporters
此回答整理自钉群“魔搭ModelScope开发者联盟群 ①”