"# 导出模型
from modelscope.models import Model
from modelscope.exporters import Exporter
model_id = 'damo/nlp_mt5_zero-shot-augment_chinese-base'
model = Model.from_pretrained(model_id)
output_files = Exporter.from_model(model).export_onnx(
candidate_labels=['文化', '体育', '娱乐', '财经', '家居', '汽车', '教育', '科技', '军事'], output_dir='/tmp')
print(output_files)
from modelscope.preprocessors import Preprocessor
preprocessor = Preprocessor.from_pretrained('damo/nlp_mt5_zero-shot-augment_chinese-base')
import onnxruntime as ort
ort_session = ort.InferenceSession('/tmp/model.onnx')
outputs = ort_session.run(['logits'], dict(preprocessor('text1',
candidate_labels=['文化', '体育', '娱乐', '财经', '家居', '汽车', '教育', '科技', '军事'],
return_tensors='np')))
print(outputs)
为什么不能正确导出ModelScope模型?"
ModelScope旨在打造下一代开源的模型即服务共享平台,为泛AI开发者提供灵活、易用、低成本的一站式模型服务产品,让模型应用更简单!欢迎加入技术交流群:微信公众号:魔搭ModelScope社区,钉钉群号:44837352