python - caffe 到 onnx 的 libcaffeconverter 导入错误
问题描述
问题描述
我正在关注https://github.com/onnx/onnx-docker/blob/master/onnx-ecosystem/converter_scripts/caffe_coreml_onnx.ipynb上的 caffe to onnx 教程,我遇到了这个错误: ImportError: cannot import name 'libcaffeconverter '来自'coremltools'
经过进一步调查,我意识到 coremltools 目录中没有 libcaffeconverter。
系统信息
操作系统平台和分发:Windows 10 x64 ONNX 版本:1.7.0 Python 版本:3.7.7 Protobuf 版本:3.13.0 Visual Studio 版本(如果适用):2017 版本 15.9.28307.1234
复制说明
创建一个新环境并运行“pip install coremltools==4.0b3”
在https://github.com/onnx/onnx-docker/blob/master/onnx-ecosystem/converter_scripts/caffe_coreml_onnx.ipynb运行代码
或者
跑:
导入 coremltools coremltools.converters.caffe.convert(None)
预期行为
我希望代码根据代码中指定的 caffe 文件创建并保存一个 onnx 文件
解决方案
TL;DR:切换到 python 3.6
像问题所在的 OP 一样import coremltools coremltools.converters.caffe.convert(None)
,产生 `ImportError: cannot import name 'libcaffeconverter' 这可以通过在 python 3.6 中使用虚拟环境来避免
解决方法:
在终端中使用您选择的包管理器创建一个 python 3.6 环境:
conda create -n <your env name here> python=3.6 anaconda
或virtualenv --python=/usr/bin/python3.6
激活虚拟环境
conda activate <your env name here>
(或 pip 等价物)导航到您的项目目录并运行您的文件
python <your script here>.py
现在它应该按计划工作
推荐阅读
- python-3.x - onvif 从 ip-camera 检索日志文件
- node.js - Express 服务器重定向到 React 路由器 404 未找到
- java - Java 扫描器类从文本文件中读取制表符分隔的字符串
- firebase - Firebase按钮onClick,设置UID子
- python - 每次通过在python中调用相同的方法运行程序时,如何获得不同的输出?
- sql-server - Dapper Execute 返回 -1 值?
- superset - apache superset dashbaord没有渲染
- javascript - Nativescript - 通过代码添加 ActionBar
- python - 如何将数组切片为序列数组?
- java - 在java中从文件中读取和解析。我怎样才能让它读取和打印狮子等的详细信息