博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Caffe (卷积神经网络框架) Convolutional Architecture for Fast Feature Embedding
阅读量:2171 次
发布时间:2019-05-01

本文共 7714 字,大约阅读时间需要 25 分钟。

  • Introduction
    Caffe (卷积神经网络框架)
    Caffe,全称Convolutional Architecture for Fast Feature Embedding。是一种常用的深度学习框架,主要应用在视频、图像处理方面的应用上。
    caffe是一个清晰,可读性高,快速的深度学习框架。作者是贾扬清,加州大学伯克利的ph.D,现就职于Facebook。caffe的官网是。

Caffe community:

Caffe code:

  • porting
    downloading: git clone

Following are the commands used:

#Install prerequisites for ubuntu16.04sudo apt-get install libprotobuf-devsudo apt-get install libleveldb-devsudo apt-get install libsnappy-devsudo apt-get install libopencv-devsudo apt-get install libhdf5-serial-devsudo apt-get install protobuf-compilersudo apt-get install libgflags-devsudo apt-get install libgoogle-glog-devsudo apt-get install liblmdb-devsudo apt-get install libatlas-base-devsudo apt-get install --no-install-recommends libboost-all-devsudo make allsudo make testsudo make runtestfinally, following will be seen:[----------] Global test environment tear-down[==========] 1158 tests from 152 test cases ran. (41526 ms total)[  PASSED  ] 1158 tests.python caffe:sudo apt-get install python-pipsudo apt-get install gfortrancd ~/caffe/pythonfor req in $(cat requirements.txt); do pip install $req; done#reinstall dateutil if neededsudo apt-get remove --auto-remove python-dateutilsudo apt-get purge --auto-remove python-dateutil#Download python_dateutil-2.7.3-py2.py3-none-any.whl from https://pypi.org/project/python-dateutil/2.7.1/pip install python_dateutil-2.7.3-py2.py3-none-any.whlpip list | grep dateutilmake pycaffe#checkpythonimport caffe#if no error was reported, it has beened installed in python.

Following is the details when I tried to run caffe on ubuntu16.04.

It mainly follows .
Another link seems to be helpful too (Try in another pc?)

Install prerequisites:sudo apt-get install libprotobuf-devsudo apt-get install libleveldb-devsudo apt-get install libsnappy-devsudo apt-get install libopencv-devsudo apt-get install libhdf5-serial-devsudo apt-get install protobuf-compilersudo apt-get install libgflags-devsudo apt-get install libgoogle-glog-devsudo apt-get install liblmdb-devsudo apt-get install libatlas-base-devgit clone git://github.com/BVLC/caffe.gitcd caffecp Makefile.config.example Makefile.config#make following changes to Makefile.config    :~/work/ai/opensource/caffe$ diff Makefile.config.example Makefile.config    8c8    < # CPU_ONLY := 1    ---    >  CPU_ONLY := 1    95,96c95,96    < INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include    < LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib    ---    > INCLUDE_DIRS := $(PYTHON_INCLUDE) /usr/local/include /usr/include/hdf5/serial    > LIBRARY_DIRS := $(PYTHON_LIB) /usr/local/lib /usr/lib /usr/lib/x86_64-linux-gnu/hdf5/serial:~/work/ai/opensource/caffe$ sudo make allPROTOC src/caffe/proto/caffe.protoCXX .build_release/src/caffe/proto/caffe.pb.ccCXX src/caffe/solver.cppsrc/caffe/solver.cpp:6:38: fatal error: boost/algorithm/string.hpp: No such file or directorycompilation terminated.Makefile:581: recipe for target '.build_release/src/caffe/solver.o' failedmake: *** [.build_release/src/caffe/solver.o] Error 1sudo apt-get install libboost-devsudo make all#following errors are seen:/usr/bin/ld: cannot find -lboost_system/usr/bin/ld: cannot find -lboost_filesystem/usr/bin/ld: cannot find -lboost_threadcollect2: error: ld returned 1 exit statussudo apt-get install --no-install-recommends libboost-all-dev# continue to makesudo make allsudo make testsudo make runtestfinally, following will be seen:[----------] Global test environment tear-down[==========] 1158 tests from 152 test cases ran. (41526 ms total)[  PASSED  ] 1158 tests.# pythonsudo apt-get install python-pipsudo apt-get install gfortran#cat ./python/requirements.txtcd ~/caffe/pythonfor req in $(cat requirements.txt); do pip install $req; donesudo pip install -r requirements.txt#安装成功的,都会显示Requirement already satisfied,没安装成功的,会继续进行安装Command "python setup.py egg_info" failed with error code 1 in /tmp/pip-build-zu_pEe/ipython/You are using pip version 8.1.1, however version 10.0.1 is available.You should consider upgrading via the 'pip install --upgrade pip' command.pip install --upgrade pipRequirement already up-to-date: pip in /home/csr/.local/lib/python2.7/site-packages (10.0.1):~/work/ai/opensource/caffe/python$ sudo pip install -r requirements.txtTraceback (most recent call last):  File "/usr/bin/pip", line 9, in 
from pip import mainImportError: cannot import name mainhttps://www.cnblogs.com/dylan9/p/8981155.htmlcd /usr/binsudo vi pipimport reimport sysfrom pip._internal import main as _mainif __name__ == '__main__':  sys.argv[0] = re.sub(r'(-script\.pyw?|\.exe)?$', '', sys.argv[0])  sys.exit(_main())sudo pip install -r requirements.txtthen:pandas 0.23.0 has requirement python-dateutil>=2.5.0, but you'll have python-dateutil 1.5 which is incompatible.matplotlib 2.2.2 has requirement python-dateutil>=2.1, but you'll have python-dateutil 1.5 which is incompatible.sudo pip install python-dateutil --upgradeFor Ubuntu:uninstall python-dateutil and it's dependenciessudo apt-get remove --auto-remove python-dateutilpurging your config/data toosudo apt-get purge --auto-remove python-dateutilreinstall it#sudo apt-get install python-dateutilDownload python_dateutil-2.7.3-py2.py3-none-any.whl from https://pypi.org/project/python-dateutil/2.7.1/sudo -H pip install python_dateutil-2.7.3-py2.py3-none-any.whl:~/work/ai/opensource/caffe$ pip list | grep dateutilpython-dateutil 2.7.3:~/work/ai/opensource/caffe$ sudo pip install -r requirements.txtThe directory '/home/csr/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.The directory '/home/csr/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt':~/work/ai/opensource/caffe$ pip install -r requirements.txtCould not open requirements file: [Errno 2] No such file or directory: 'requirements.txt':~/work/ai/opensource/caffe$:~/work/ai/opensource/caffe$ sudo -H pip install -r requirements.txtTraceback (most recent call last): File "/usr/bin/pip", line 7, in
from pip._internal import main as _mainImportError: No module named _internalAn answer from askUbuntu works.you can at firstcurl https://bootstrap.pypa.io/get-pip.py -o get-pip.pythenpython2.7 get-pip.py --force-reinstallto reinstall pip.#execute it again:sudo -H pip install -r requirements.txt:~/work/ai/opensource/caffe$ make pycaffeCXX/LD -o python/caffe/_caffe.so python/caffe/_caffe.cpppython/caffe/_caffe.cpp:10:31: fatal error: numpy/arrayobject.h: No such file or directorycompilation terminated.Change as following:--- a/Makefile.config+++ b/Makefile.config@@ -67,7 +67,7 @@ BLAS := atlas # NOTE: this is required only if you will compile the python interface. # We need to be able to find Python.h and numpy/arrayobject.h. PYTHON_INCLUDE := /usr/include/python2.7 \- /usr/lib/python2.7/dist-packages/numpy/core/include+ /usr/local/lib/python2.7/dist-packages/numpy/core/includeThen,make pycaffeFinally, "import caffe" can be run in python.
  • Recognize based on

./build/examples/cpp_classification/classification.bin \

examples/mnist/deploy.prototxt \
examples/mnist/lenet_iter_10000.caffemodel \
examples/mnist/mean.binaryproto \
examples/mnist/synset_words.txt \
examples/images/3.jpg
———- Prediction for examples/images/num_3.bmp ———-
1.0000 - “3”
0.0000 - “4”
0.0000 - “1”
0.0000 - “0”
0.0000 - “2”

你可能感兴趣的文章
图解什么是 Transformer
查看>>
代码实例:如何使用 TensorFlow 2.0 Preview
查看>>
6 种用 LSTM 做时间序列预测的模型结构 - Keras 实现
查看>>
走进JavaWeb技术世界1:JavaWeb的由来和基础知识
查看>>
走进JavaWeb技术世界2:JSP与Servlet的曾经与现在
查看>>
走进JavaWeb技术世界3:JDBC的进化与连接池技术
查看>>
走进JavaWeb技术世界4:Servlet 工作原理详解
查看>>
走进JavaWeb技术世界5:初探Tomcat的HTTP请求过程
查看>>
走进JavaWeb技术世界6:Tomcat5总体架构剖析
查看>>
走进JavaWeb技术世界7:Tomcat和其他WEB容器的区别
查看>>
走进JavaWeb技术世界9:Java日志系统的诞生与发展
查看>>
走进JavaWeb技术世界10:从JavaBean讲到Spring
查看>>
走进JavaWeb技术世界11:单元测试框架Junit
查看>>
走进JavaWeb技术世界12:从手动编译打包到项目构建工具Maven
查看>>
走进JavaWeb技术世界13:Hibernate入门经典与注解式开发
查看>>
走进JavaWeb技术世界14:Mybatis入门
查看>>
走进JavaWeb技术世界16:极简配置的SpringBoot
查看>>
初探Java设计模式1:创建型模式(工厂,单例等)
查看>>
初探Java设计模式2:结构型模式(代理模式,适配器模式等)
查看>>
初探Java设计模式3:行为型模式(策略,观察者等)
查看>>