SegNet安装运行

来源:互联网 发布:nginx php fpm 编辑:程序博客网 时间:2024/05/16 10:43

SegNet是英国剑桥大学Computer Vision and Robotics Group的作品;是一个深度卷积编码-解码结构,用于对图像进行像素级的语义分割;可以将像素分为12类,包括道路、建筑物、电线杆、路牌、行人和骑行者等12类标注,具有实时性;其源代码在github上。

1. 安装

首先下载SegNet并解压。因为它是给予caffe实现的,所以先编译过程和要求与caffe相同。
1.按照博客 Ubuntu14.04通过make+cmake编译安装caffe 的第一步准备依赖环境。
2.安装各种需要用到的库

sudo apt-get install python-matplotlibsudo apt-get install python-scipysudo apt-get install python-opencvsudo apt-get install python-protobufwget https://bootstrap.pypa.io/get-pip.py  --no-check-certificatesudo python get-pip.pysudo pip install -U scikit-image

3.编译
进入主目录

cp Makefile.config.example Makefile.config

修改Makefile.config,注意将WITH_PYTHON_LAYER := 1前的注释去掉。

make allmake pycaffemake test

2. 运行Webcam Demo

去https://github.com/alexgkendall/SegNet-Tutorial下载目录并解压。去http://mi.eng.cam.ac.uk/~agk34/resources/SegNet/下载对应的权重参数
修改Scripts/webcam_demo.py的14行为你安装的SegNet,我的为caffe_root = '/home/gph/Desktop/caffe-segnet-segnet-cleaned'
调用命令即可运行:

python Scripts/webcam_demo.py --model Example_Models/segnet_model_driving_webdemo.prototxt --weights /Example_Models/segnet_weights_driving_webdemo.caffemodel --colours /Scripts/camvid12.png

3. 问题记录

1. No module named matplotlib.pyplot

Traceback (most recent call last):
File “Scripts/webcam_demo.py”, line 2, in
import matplotlib.pyplot as plt
ImportError: No module named matplotlib.pyplot

sudo apt-get install python-matplotlib

2. No module named scipy

ImportError: No module named scipy

sudo apt-get install python-scipy  

3. No module named cv2

ImportError: No module named cv2

sudo apt-get install python-opencv

4. No module named caffe

Traceback (most recent call last):
File “Scripts/webcam_demo.py”, line 16, in
import caffe
ImportError: No module named caffe

export PYTHONPATH=/home/gph/Desktop/caffe-segnet-segnet-cleaned/python

5. No module named _caffe

Traceback (most recent call last):
File “Scripts/webcam_demo.py”, line 16, in
import caffe
File “/home/gph/Desktop/caffe-segnet-segnet-cleaned/python/caffe/init.py”, line 1, in
from .pycaffe import Net, SGDSolver
File “/home/gph/Desktop/caffe-segnet-segnet-cleaned/python/caffe/pycaffe.py”, line 13, in
from ._caffe import Net, SGDSolver
ImportError: No module named _caffe

gph@gph-pc:~/Desktop/caffe-segnet-segnet-cleaned$ make pycaffe

6. KeyError: ‘argmax’

Traceback (most recent call last):
File “Scripts/webcam_demo.py”, line 32, in
output_shape = net.blobs[‘argmax’].data.shape
KeyError: ‘argmax’

模型文件不对

7. Check failed: error == cudaSuccess (2 vs. 0) out of memory

显存不够

0 0
原创粉丝点击