安装onnx

1、安装pip【https://blog.csdn.net/quantum7/article/details/83543591】

sudo apt-get install python-pip         #python2

sudo apt-get install python3-pip      #python3

2、caffe安装(ubantu>=17)【http://caffe.berkeleyvision.org/install_apt.html】

sudo apt install caffe-cpu
cpu版本

3、caffe2安装(ubantu18.04)

通过anaconda安装的

a、先安装anaconda:【https://www.howtoing.com/how-to-install-anaconda-on-ubuntu-18-04-quickstart】【私密】

不要根据curl -0 那个方法下载,我用curl下载完,找不到下载的东西在哪。我用浏览器下的,这时下载的文件在Downloads文件夹下。根据上面的教程就安装好了。

anaconda教程【https://docs.anaconda.com/anaconda/】

 

b、然后安装caffe2:【https://caffe2.ai/docs/getting-started.html?platform=ubuntu&configuration=prebuilt#anaconda-install-path】

 创建一个新的环境安装caffe2

conda install pytorch-nightly-cpu -c pytorchca
caffe2的cpu版本

4、onnx的安装  官方文档【https://github.com/onnx/onnx】

我使用的文档【https://blog.csdn.net/mengdeyuanterry/article/details/79750065】

conda install -c conda-forge onnx

conda install -c conda-forge protobuf numpy

pip install onnx

 5、caffe2环境有了,onnx也能正常导入了,在根据官方文档进行测试时【https://github.com/onnx/tutorials/blob/master/tutorials/OnnxCaffe2Import.ipynb】,还是报错了,如下

           Import Error: no module named 'past'

解决方法:pip install future   【https://www.cnblogs.com/huolifeng/p/6412183.html】

接下来就是下载 squeezenet.onnx【https://github.com/onnx/models/tree/master/squeezenet】

6、为了导入你们俩,把哥哥害苦了,

安装onnx_第1张图片

7、onnx模型转换成caffe2运行的模型时

convert-onnx-to-caffe2 assets/squeezenet.onnx --output predict_net.pb --init-net-output init_net.pb

报错:ModuleNotFoundError: No module named 'click'

        pip install click    【https://github.com/alexwlchan/backup_tumblr/issues/10】

注:不要用pip3安装,pip3安装时,系统会说已经安装好了,但是如果用conda list查看时,发现并没有相关的模块

安装onnx_第2张图片

总结:这个博客的主要目的是记录一下由onnx模型转caffe2模型的探索过程。在ubunatu系统上先由anaconda安装caffe2,然后再安装onnx。最后根据文档进行操作,不过这怎么产生俩个pb文件,pb文件不应该是tensorflow框架产生的吗,caffe不应该产生.prototxt和.caffemodel文件吗。。。一山放过一山拦,爬了一坑又一坑

你可能感兴趣的:(深度学习,树莓派,Linux)