贴上具体的编译过程吧:
step1:clone下caffe,按照caffe官方教程编译caffe(要编译python接口)
step2:进入到PSPNet里面进行编译,编译过程和caffe的编译差不多,在这里我使用了python接口,所以进行以下语句的编译即可:
make pycaffe -j4
make all -j4
make test -j4
在编译pycaffe是可能会出现以下错误:
如果不适用GPU的话在interp.hpp直接注释掉这条语句即可;
还可能出现下面这个错误:
sudo apt-get install libmatio-dev安装一下就好。
step3:在PSPNet下面建立demo文件夹
下载相应的caffemodel和prototxt文件,然后修改demo.py就可以用训练好的模型进行测试:
import sys
import time
import getopt
import os
import numpy as np
from PIL import Image as PILImage
# Path of the Caffe installation.
_CAFFE_ROOT = "/home/chen/PSPNet/"
# Model definition and model file paths
_MODEL_DEF_FILE = "pspnet50_ADE20K_473.prototxt" # Contains the network definition
_MODEL_FILE = "pspnet50_ADE20K.caffemodel" # Contains the trained weights.
sys.path.insert(0, _CAFFE_ROOT + "python")
import caffe
_MAX_DIM = 473
def get_palette(num_cls):
""" Returns the color map for visualizing the segmentation mask.
Args:
num_cls: Number of classes
Returns:
The color map
"""
n = num_cls
palette = [0] * (n