打开微信,使用扫一扫进入页面后,点击右上角菜单,
点击“发送给朋友”或“分享到朋友圈”完成分享
yolov8模型转换:
if [ ! -f /app/project/best.onnx ];then
echo "export model begin..."
cd $PROJ_ROOT_PATH/export_model/ultralytics/
python3.8 setup.py install
yolo task=detect mode=export model=/app/project/best.pt format=onnx source=${PROJ_ROOT_PATH}/export_model/ultralytics/assets/bus.jpg opset=11 dynamic=true simplify=true
echo "export model end..."
fi
报错:
ONNX: starting export with onnx 1.12.0 opset 11...
/usr/local/lib/python3.8/dist-packages/torch/tensor.py:590: RuntimeWarning: Iterating over a tensor might cause the trace to be incorrect. Passing a tensor of different shape won't change the number of iterations executed (and might lead to errors or silently give incorrect results).
warnings.warn('Iterating over a tensor might cause the trace to be incorrect. '
ERROR ❌ ONNX: export failure 0.5s: Exporting the operator silu to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.
Traceback (most recent call last):
File "/usr/local/bin/yolo", line 11, in <module>
load_entry_point('ultralytics==8.3.133', 'console_ s', 'yolo')()
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/cfg/__init__.py", line 981, in entrypoint
getattr(model, mode)(**overrides) # default args from model
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/engine/model.py", line 730, in export
return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model)
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/engine/exporter.py", line 461, in __call__
f[2], _ = self.export_onnx()
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/engine/exporter.py", line 197, in outer_func
raise e
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/engine/exporter.py", line 192, in outer_func
f, model = inner_func(*args, **kwargs)
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/engine/exporter.py", line 582, in export_onnx
export_onnx(
File "/app/magicmind_cloud/buildin/cv/detection/yolov8_pytorch/export_model/ultralytics/ultralytics/utils/export.py", line 35, in export_onnx
torch.onnx.export(
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/__init__.py", line 225, in export
return utils.export(model, args, f, export_params, verbose, training,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 85, in export
_export(model, args, f, export_params, verbose, training, input_names, output_names,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 632, in _export
_model_to_graph(model, args, verbose, input_names,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 417, in _model_to_graph
graph = _optimize_graph(graph, operator_export_type,
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 203, in _optimize_graph
graph = torch._C._jit_pass_onnx(graph, operator_export_type)
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/__init__.py", line 263, in _run_symbolic_function
return utils._run_symbolic_function(*args, **kwargs)
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 930, in _run_symbolic_function
symbolic_fn = _find_symbolic_in_registry(domain, op_name, opset_version, operator_export_type)
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/utils.py", line 888, in _find_symbolic_in_registry
return sym_registry.get_registered_op(op_name, domain, opset_version)
File "/usr/local/lib/python3.8/dist-packages/torch/onnx/symbolic_registry.py", line 111, in get_registered_op
raise RuntimeError(msg)
RuntimeError: Exporting the operator silu to ONNX opset version 11 is not supported. Please open a bug to request ONNX export support for the missing operator.
官方gitee文档里解释如下:
由于 MagicMind 最高支持 PyTorch 1.6.0 版本,此版本没有 SiLU 函数,所以要在环境中修改代码如下:
vim /usr/lib/python3.7/site-packages/torch/nn/modules/activation.py# 进行如下修改return F.silu(input, inplace=self.inplace) 替换为 return input * torch.sigmoid(input)
但是我的activation.py并没有
return F.silu(input, inplace=self.inplace)
热门帖子
精华帖子