sam和mobilesam导出onnx的问题

环境:python==3.10,torchvision==0.12.0+cu113  onnx==1.12.0   onnxruntime==1.13.1

一、问题

我们在mobilesam工程(sam工程一样的)导出onnx的时候默认出现:

”ValueError: Unsupported ONNX opset version: 16“

然后我们就按照一些资料,将opset降低到使用13,结果还是不行:

repeat_interleave
for idx, r_split in enumerate(r_splits):
TypeError: 'torch._C.Value' object is not iterable
(Occurred when translating repeat_interleave).

二、解决方法

(1)升级pytorch版本

I create a new conda env, use pytorch=1.12, and opset=13, solve the problem.

Try PyTorch 2.0. The requirements are likely PyTorch 2.0 and opset version 17.

(2)修改源码

/home/wt-yjy/miniconda3/envs/sam/lib/python3.10/site-packages/mobile_sam/modeling/mask_decoder.py

修改后:


你可能感兴趣的:(深度学习算法部署,ONNX,深度学习,人工智能)