[常用工具] Caffe ssd常见问题集合
1 Check failed: a <= b <0 vs -1.19209e-007>
网上办法是注释掉 CHECK_LE(a, b),但是这样会出大问题。解决办法见2。
如果注释掉 CHECK_LE(a, b) 会出现Data layer prefetch queue empty
不注释CHECK_LE(a, b) 会出现错误 a可能大于b
2 training error: Data layer prefetch queue empty
这种问题出现通常是注释掉 CHECK_LE(a, b) 出现Data layer prefetch queue empty。导致程序出现死循环。
解决办法修改src/caffe/util/sampler.cpp,如下面修改代码所示//renew注释下,加入两个判断,使得bbox长宽不要越界。
void SampleBBox(const Sampler& sampler, NormalizedBBox* sampled_bbox) {
// Get random scale.
CHECK_GE(sampler.max_scale(), sampler.min_scale());
CHECK_GT(sampler.min_scale(), 0.);
CHECK_LE(sampler.max_scale(), 1.);
float scale;
caffe_rng_uniform(1, sampler.min_scale(), sampler.max_scale(), &scale);
// Get random aspect ratio.
CHECK_GE(sampler.max_aspect_ratio(), sampler.min_aspect_ratio());
CHECK_GT(sampler.min_aspect_ratio(), 0.);
CHECK_LT(sampler.max_aspect_ratio(), FLT_MAX);
float aspect_ratio;
caffe_rng_uniform(1, sampler.min_aspect_ratio(), sampler.max_aspect_ratio(),
&aspect_ratio);
aspect_ratio = std::max<float>(aspect_ratio, std::pow(scale, 2.));
aspect_ratio = std::min<float>(aspect_ratio, 1 / std::pow(scale, 2.));
// Figure out bbox dimension.
float bbox_width = scale * sqrt(aspect_ratio);
float bbox_height = scale / sqrt(aspect_ratio);
//renew
if(bbox_width>=1.0)
{
bbox_width=1.0;
}
if(bbox_height>=1.0)
{
bbox_height=1.0;
}
// Figure out top left coordinates.
float w_off, h_off;
caffe_rng_uniform(1, 0.f, 1 - bbox_width, &w_off);
caffe_rng_uniform(1, 0.f, 1 - bbox_height, &h_off);
sampled_bbox->set_xmin(w_off);
sampled_bbox->set_ymin(h_off);
sampled_bbox->set_xmax(w_off + bbox_width);
sampled_bbox->set_ymax(h_off + bbox_height);
}
3 配置SSD-caffe测试时出现“Check failed: error == cudaSuccess (10 vs. 0) invalid device ordinal”解决
运行 python examples/ssd/ssd_pascal.py 时报错
解决方法:将ssd_pascal.py文件中第332行gpus = “0,1,2,3”的GPU选择改为gpus = “0”,后面的1,2,3都删掉即可。再次训练即可。当然,只有一块GPU且电脑运行内存有限,还需要将ssd_pascal.py文件中的337行batch_size = 32和338行accum_batch_size = 32都改小一倍,即更改批量大小,不然会出现“Check failed: error == cudaSuccess (2 vs. 0) invalid …”的错误。
4 配置SSD-caffe出现“ AttributeError: ‘module’ object has no attribute ‘LabelMap’”解决
这是由于caffe的Python环境变量未配置好,可按照下面方法解决:
vim ~/.bashrc
加入 export PYTHONPATH=/SSD所在目录/caffe/python
source ~/.bashrc
本文来自博客园,作者:落痕的寒假,转载请注明原文链接:https://www.cnblogs.com/luohenyueji/p/16970329.html
![](https://gitcode.net/LuohenYJ/article_picture_warehouse/-/raw/main/wechat/content/%E5%8A%A0%E6%B2%B9%E9%B8%AD.gif)