在进行segnet 编译与测试时出现的错误
1.在执行sudo make all -j4的时候,出现了以下错误,报错提示说在caffe-segnet/src/caffe/layers的路径下的contrastive_loss_layer.cpp出错
CXX src/caffe/layers/multinomial_logistic_loss_layer.cpp
src/caffe/layers/contrastive_loss_layer.cpp: In instantiation of ‘void caffe::ContrastiveLossLayer<Dtype>::Forward_cpu(const std::vector<caffe::Blob<Dtype>*>&, const std::vector<caffe::Blob<Dtype>*>&) [with Dtype = float]’:
src/caffe/layers/contrastive_loss_layer.cpp:118:1: required from here
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));
^
In file included from /usr/include/c++/5/algorithm:61:0,
from src/caffe/layers/contrastive_loss_layer.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> const _Tp& std::max(const _Tp&, const _Tp&)
max(const _Tp& __a, const _Tp& __b)
^
/usr/include/c++/5/bits/stl_algobase.h:219:5: note: template argument deduction/substitution failed:
src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘float’)
Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));
^
In file included from /usr/include/c++/5/algorithm:61:0,
from src/caffe/layers/contrastive_loss_layer.cpp:1:
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
max(const _Tp& __a, const _Tp& __b, _Compare __comp)
^
/usr/include/c++/5/bits/stl_algobase.h:265:5: note: template argument deduction/substitution failed:
src/caffe/layers/contrastive_loss_layer.cpp:56:30: note: deduced conflicting types for parameter ‘const _Tp’ (‘double’ and ‘float’)
Dtype dist = std::max(margin - sqrt(dist_sq_.cpu_data()[i]), Dtype(0.0));
^
Makefile:526: recipe for target '.build_release/src/caffe/layers/contrastive_loss_layer.o' failed
make: *** [.build_release/src/caffe/layers/contrastive_loss_layer.o] Error 1
make: *** 正在等待未完成的任务....
2.
在执行sudo python ./Scripts/test_segmentation_camvid.py --model Models/segnet_basic_inference.prototxt --weights ./Example_Models/segnet_weights_driving_webdemo.caffemodel --iter 1的时候出现的错误:
解决方案:
安装需要用到的库:
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.后面又出现了这个错误:
Traceback (most recent call last):
File "./Scripts/test_segmentation_camvid.py", line 14, in <module>
import caffe
ImportError: No module named caffe
解决方案:
发现这里在配置caffe_root路径时少打了个/,正确的应该是'xxx/cafe-segnet/'
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 智能桌面机器人:用.NET IoT库控制舵机并多方法播放表情
· Linux glibc自带哈希表的用例及性能测试
· 深入理解 Mybatis 分库分表执行原理
· 如何打造一个高并发系统?
· .NET Core GC压缩(compact_phase)底层原理浅谈
· 新年开篇:在本地部署DeepSeek大模型实现联网增强的AI应用
· DeepSeek火爆全网,官网宕机?本地部署一个随便玩「LLM探索」
· Janus Pro:DeepSeek 开源革新,多模态 AI 的未来
· 上周热点回顾(1.20-1.26)
· 【译】.NET 升级助手现在支持升级到集中式包管理