安装caffe-segnet

参考https://blog.youkuaiyun.com/u013832707/article/details/53670830

1. 安装

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

sudo apt-get install python-matplotlib
sudo apt-get install python-scipy
sudo apt-get install python-opencv
sudo apt-get install python-protobuf
wget https://bootstrap.pypa.io/get-pip.py  --no-check-certificate
sudo python get-pip.py
sudo pip install -U scikit-image

过程中遇到各种依赖问题,自行搜索可得到很多解决方案。

3.编译 
进入主目录

cp Makefile.config.example Makefile.config

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

make all
make pycaffe
make test

在编译过程中遇到很多问题:

 

2. 运行Webcam Demo

https://github.com/alexgkendall/SegNet-Tutorial下载目录并解压。在/SegNet-Tutorial文件夹下去http://mi.eng.cam.ac.uk/~agk34/resources/SegNet/下载对应的权重参数:wget  http://mi.eng.cam.ac.uk/~agk34/resources/SegNet/segnet_weights_driving_webdemo.caffemodel

修改Scripts/webcam_demo.py的14行为你安装的SegNet,我的为caffe_root = '/home/zml/.....'
SegNet-Tutorial下调用命令即可运行:

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

注意:

解决办法:

 修改Makefile: 

    LIBRARIES += glog gflags protobuf leveldb snappy lmdb boost_system hdf5_hl hdf5 m opencv_core opencv_highgui         opencv_imgproc
    增加 : opencv_imgcodecs
  1. 遇到的错误及解决办法./include/caffe/util/device_alternate.hpp:34:23: fatal error: cublas_v2.h: 没有那个文件或目录。这里是编译依赖了GPU的一些库,在配置文件中解除注释 CPU_ONLY := 1就行了;
  2. src/caffe/layers/contrastive_loss_layer.cpp:56:30: error: no matching function for call to ‘max(double, float)’Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));          

       解决:替换contrastive_loss_layer.cpp的56行:Dtype dist = std::max(margin - (float)sqrt(dist_sq_.cpu_data()[i]),             Dtype(0.0));       

      3. 各种对‘caffe::caffe::singleton_'未定义引用   https://github.com/BVLC/caffe/issues/3396   

     解决:sudo rm /usr/local/lib/libcaffe.*  主要是因为之前安装了原版的caffe,对新安装的caffe-segnet有影响。

  4.make test 时(出错:include/caffe/test/test_gradient_check_util.hpp error: no matching function for call to ‘max(conest double&,float ) 

     解决: 修改test_gradient_check_util.hpp 错误一行为(float)(std::max(fabs(computed_gradient), fabs(estimated_gradient))), (float)1.);   

 

可能出现问题:

①libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 19:12: Message type "caffe.LayerParameter" has no field named "bn_param".
F1006 14:45:42.856966 15514 upgrade_proto.cpp:88] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: models/ucf101/tsn_bn_inception_rgb_deploy.prototxt
*** Check failure stack trace: ***
Aborted (core dumped)     

 分析:可能是原来安装的caffe对caffe-segnet有影响,要修改为caffe-segnet ,我只是重新安装了一下caffe-segnet。

②忘记修改cpu模式:F0822 21:57:53.386196 38133 conv_layer.cpp:71] Cannot use GPU in CPU-only Caffe: check mode. *** Check failure stack trace: *** Aborted (core dumped)

webcam_demo.py的30行, 修改 caffe.set_mode_gpu() to caffe.set_mode_cpu()

 

cpu跑代码真的真的很慢很慢,无奈

评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值