环境: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
修改后: