一、配置环境(ubuntu16.04+virtual box)
1.下载OpenCV并安装
下载方法:git clone https://github.com/opencv/opencv.git
执行以下命令安装相应依赖:
sudo apt-get install git cmake build-essential pkg-config libgtk2.0-dev libssl-dev libv4l-dev v4l-utils libjpeg-dev libtiff5-dev libjasper-dev libpng-dev libavcodec-dev libavformat-dev libswscale-dev libxvidcore-dev libx264-dev libxine2-dev libgstreamer1.0-dev libgstreamer-plugins-base1.0-dev libqt4-dev libgtk-3-dev mesa-utils libgl1-mesa-dri libqt4-opengl-dev libatlas-base-dev gfortran libeigen3-dev python2.7-dev python3-dev python-numpy python3-numpy
下载完毕后,cd到下载目录,执行以下命令:
sudo remote update
sudo checkout 3.4.1
sudo mkdir build_cmake
sudo cd build_cmake
sudo cmake ..
sudo make
sudo make install
sudo ldconfig -v
2.下载Caffe并安装
下载方法:sudo git clone https://github.com/BVLC/caffe.git
依次执行:
sudo apt-get install libatlas-base-dev
sudo apt-get install libprotobuf-dev
sudo apt-get install libleveldb-dev
sudo apt-get install libsnappy-dev
sudo apt-get install libopencv-dev
sudo apt-get install libboost-all-dev
sudo apt-get install libhdf5-serial-dev
sudo apt-get install libgflags-dev
sudo apt-get install libgoogle-glog-dev
sudo apt-get install liblmdb-dev
sudo apt-get install protobuf-compiler
caffe工程下载完毕后,到对应的目录进行解压并进入解压后的目录,
sudo make all
sudo make pycaffe
二、运行caffe带的demo
执行命令: sudo sh data/mnist/get_mnist.sh下载数据:
执行命令:sudo sh examples/mnist/create_mnist.sh对数据进行转换会生成mnist_test_lmdb和mnist_train_lmdb文件:
执行命令:sudo sh examples/mnist/train_lenet.sh训练模型,大概十几分钟后: