CRFasRNN Model Guide

This blog mainly talks about the guidelines on the usage of the model for image semantic segmentation published on ICCV2015. (I am not talented, and I have been running for more than a week. I must write down all the mistakes of vomiting blood).

Source URL http://crfasrnn.torr.vision/ 

Paper URL: http://www.robots.ox.ac.uk/~szheng/papers/CRFasRNN.pdf

At the beginning, the blogger is the model under the above source code URL, but because the caffe in his environment does not contain the crfasrnn model, and the configuration is not successful according to the description on git, I saw the caffe for crfasrnn shared by torrvision when I was in a hurry. Source code, URL: https://github.com/torrvision/caffe/tree/crfrnn  . Be sure to download this! ! !

After the download is complete:

1. Put the caffe-crfrnn folder under the project folder crfasrnn-master

2. Configure the caffe environment. Since the server used by the blogger has already installed the caffe environment, this blog post only explains the changes required to configure caffe-crfrnn: (caffe configuration reference https://blog.csdn.net/ babytang008/article/details/78631776 )

    ① Install dependencies

sudo apt-get install libprotobuf-dev libleveldb-dev libsnappy-dev libopencv-dev libhdf5-serial-dev protobuf-compiler

sudo apt-get install --no-install-recommends libboost-all-dev

sudo apt-get install libgflags-dev libgoogle-glog-dev liblmdb-dev

    ②Install the python additional dependency library according to the requirements.txt in the caffe/python directory:

for req in $(cat requirements.txt); do sudo pip install $req; done

    ③ Adjust the Makefile.config file according to your needs (make as few changes as possible, remember to backup before modification)

    USE_CUDNN:=1 Use cudnn to accelerate, uncomment this line. 
    If you use 2.4 (without opencv3 installed), you don't need to worry about it.  If you install the default location, you don't need to change   it and delete it here . developer.nvidia.com/cuda-gpus  Select the blas version, here atlas is selected by default (if you need to use intel mkl in the future, you can modify it here and recompile caffe)   The default here is but pip actually installs numpy after checking and changing it Now , at the same time , add the directory   here to the matlab installation path OPENCV_VERSION 
  CUDA_DIR := /usr/local/cuda
  CUDA_ARCH :=
  BLAS :=atlas
  PYTHON_INCLUDE :=/user/lib/.../usr/local/lib/...PYTHON_LIB/usr/local/lib/
  MATLAB_DIR:= /usr/local/MATLAB/R2015b

 INCLUDE_DIRS Append here  /usr/include/hdf5/serial and open the Makefile LIBRARIES +=and hdf5_hl hdf5replace it withhdf5_serial_hl hdf5_serial 

    ④Compile caffe

cd crfasrnn-master/caffe-crfrnn
mkdir build
cd cmake
cmake -D BUILD_TIFF=ON ../
make all -j4
make pycaffe

The following error may occur when cmake:


Workaround: Enter when cmake:

sudo su
cmake -D BUILD_TIFF=ON

   ⑤ The following errors may occur during make:


   Solution: (ps. Don't believe the methods of uninstalling proto on the Internet, the last trouble is yourself)

Modify the ./bashrc file to disable anoconda, that is, just comment out the path of anaconda in the bashrc file.

source ~/.bashrc

Restart the compile window

make clean
make all -j4

⑥Run the model

first,

cd crfasrnn-master/python-scripts
python download_trained_model.sh
After downloading caffemodel, put caffemodel in the directory crfasrnn-master/caffe-crfrnn/examples/crfasrnn_segmentation,
and then
cd crfasrnn-master/caffe-crfrnn/examples/crfasrnn_segmentation

Modify the parameters in crfasrnn_demo.py, including _CAFFE_ROOT, _MODEL_DEF_FILE, _MODEL_FILE

Run the program:

python crfasrnn_demo.py
After the operation is successful, you can see output.png, and it's over.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324686280&siteId=291194637