caffe:检查失败:cv_img.data无法加载

时间:2017-07-17 03:15:32

标签: python machine-learning computer-vision caffe pycaffe

我使用python来训练一个caffe网但遇到错误:

I0717 11:05:32.177762  8677 solver.cpp:218] Iteration 0 (0 iter/s, 0.178244s/20 iters), loss = 363409
I0717 11:05:32.177825  8677 solver.cpp:237]     Train net output #0: loss = 363409 (* 1 = 363409 loss)
I0717 11:05:32.177922  8677 solver.cpp:237]     Train net output #1: tmpl = 0
I0717 11:05:32.178000  8677 solver.cpp:237]     Train net output #2: tmpo = 0
I0717 11:05:32.178014  8677 sgd_solver.cpp:105] Iteration 0, lr = 1e-10
E0717 11:05:32.186724  8703 io.cpp:80] Could not open or find file 
F0717 11:05:32.186736  8703 image_data_layer.cpp:129] Check failed: cv_img.data Could not load 
*** Check failure stack trace: ***
Aborted (core dumped)

这是我网的数据层:

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "tmpo"
  image_data_param {
    is_color: false
    source: "/home/muses/fcn-master/mo/train_o.txt"
    batch_size: 1               
    shuffle: false
  }
} 

layer {
  name: "label"
  type: "ImageData"
  top: "label"
  top: "tmpl"
  image_data_param {
    is_color: false
    source: "/home/muses/fcn-master/mo/train_l.txt"
    batch_size: 1               
    shuffle: false
  }
}  

train_l.txt: (train_o.txt与此文件大致相同)

/home/muses/fcn-master/data/vessel/train/label/01.png 0
/home/muses/fcn-master/data/vessel/train/label/02.png 0
/home/muses/fcn-master/data/vessel/train/label/03.png 0
/home/muses/fcn-master/data/vessel/train/label/04.png 0
/home/muses/fcn-master/data/vessel/train/label/05.png 0
/home/muses/fcn-master/data/vessel/train/label/06.png 0
/home/muses/fcn-master/data/vessel/train/label/07.png 0
/home/muses/fcn-master/data/vessel/train/label/08.png 0
/home/muses/fcn-master/data/vessel/train/label/09.png 0
/home/muses/fcn-master/data/vessel/train/label/10.png 0
/home/muses/fcn-master/data/vessel/train/label/11.png 0
/home/muses/fcn-master/data/vessel/train/label/12.png 0
/home/muses/fcn-master/data/vessel/train/label/13.png 0

我已检查过文件路径是否正确。所有文件都是在ubuntu14.04下编辑的。 然后我修改了io.cpp的第80行,尝试打印错误的文件名,如下所示:

if (!cv_img_origin.data) {
    LOG(INFO) << "FILENAME: " << filename;
    LOG(INFO) << "cv_read_flag: " << cv_read_flag;
    LOG(ERROR) << "Could not open or find file " << filename;
    return cv_img_origin;
  }

错误来了:

I0718 10:17:13.220021 18611 io.cpp:80] FILENAME: 
I0718 10:17:13.220058 18611 io.cpp:81] cv_read_flag: 0
E0718 10:17:13.220062 18611 io.cpp:82] Could not open or find file 
F0718 10:17:13.220067 18611 image_data_layer.cpp:129] Check failed: cv_img.data Could not load 

我无法弄清楚错误出现的原因。 非常感谢你,如果你知道原因。

2 个答案:

答案 0 :(得分:0)

你让文件可执行吗?我这样做后问题就解决了。

您可以在images文件夹中使用chmod +x *.jpgchmod +x *.png来使文件可执行。

答案 1 :(得分:0)

我遇到了同样的问题-因为在“无法打开或查找文件”之后没有显示文件名,这意味着您在火车或测试.txt的目录中有一个空行在那一刻打电话(我是文件的最后一行)。