首页 > 解决方案 > Caffe detection_evaluate_layer.cpp:56] 检查失败:bottom[1]->num() == 1 (8 vs. 1)

问题描述

我对 Caffe 很陌生。这是我第一次尝试 Caffe。

环境:

数据集:

我的 train.txt 和 test.txt 如下所示:

id03_018258_h.jpg ./annotations/vid03_018258_h.xml
vid03_121777_h.jpg ./annotations/vid03_121777_h.xml
vid03_118674_h.jpg ./annotations/vid03_118674_h.xml

标签 xml 文件如下所示:

<annotation>
  <folder>jpegimages</folder>
  <filename>vid03_230595_h.jpg</filename>
  <path>/home/alexji/caffe-workspace/dataset/jpegimages/vid03_230595_h.jpg</path>
  <source>
    <database>Unknown</database>
  </source>
  <size>
    <width>800</width>
    <height>480</height>
    <depth>3</depth>
  </size>
  <segmented>0</segmented>
  <object>
    <name>car</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
      <xmin>509</xmin>
      <ymin>271</ymin>
      <xmax>581</xmax>
      <ymax>321</ymax>
    </bndbox>
  </object>
  <object>
    <name>car</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
      <xmin>376</xmin>
      <ymin>269</ymin>
      <xmax>410</xmax>
      <ymax>305</ymax>
    </bndbox>
  </object>
  <object>
    <name>car</name>
    <pose>Unspecified</pose>
    <truncated>0</truncated>
    <difficult>0</difficult>
    <bndbox>
      <xmin>175</xmin>
      <ymin>267</ymin>
      <xmax>220</xmax>
      <ymax>302</ymax>
    </bndbox>
  </object>
</annotation>

准备训练和测试数据:

convert_imageset --shuffle --resize_height 300 --resize_width 300 ../dataset/jpegimages/  ../dataset/imagesets/trainval.txt ../dataset/train_lmdb
convert_imageset --shuffle --resize_height 300 --resize_width 300 ../dataset/jpegimages/  ../dataset/imagesets/test.txt  ../dataset/test_lmdb

执行命令:

gen_model.sh 7
caffe train -solver solver_train.prototxt -weights mobilenet_iter_73000.caffemodel

example/MobileNetSSD_train.prototxt输入的类型MobileNetSSD_test.prototxt已从“AnnotatedData”更改为“data”

错误输出:

0908 06:22:46.163384   469 net.cpp:100] Creating Layer detection_out
I0908 06:22:46.163388   469 net.cpp:434] detection_out <- mbox_loc
I0908 06:22:46.163391   469 net.cpp:434] detection_out <- mbox_conf_flatten
I0908 06:22:46.163395   469 net.cpp:434] detection_out <- mbox_priorbox
I0908 06:22:46.163400   469 net.cpp:408] detection_out -> detection_out
I0908 06:22:46.163425   469 net.cpp:150] Setting up detection_out
I0908 06:22:46.163432   469 net.cpp:157] Top shape: 1 1 1 7 (7)
I0908 06:22:46.163435   469 net.cpp:165] Memory required for data: 1293206652
I0908 06:22:46.163439   469 layer_factory.hpp:77] Creating layer detection_eval
I0908 06:22:46.163444   469 net.cpp:100] Creating Layer detection_eval
I0908 06:22:46.163447   469 net.cpp:434] detection_eval <- detection_out
I0908 06:22:46.163451   469 net.cpp:434] detection_eval <- label
I0908 06:22:46.163457   469 net.cpp:408] detection_eval -> detection_eval
F0908 06:22:46.163471   469 detection_evaluate_layer.cpp:56] Check failed: bottom[1]->num() == 1 (8 vs. 1) 
*** Check failure stack trace: ***
    @     0x7f3ac479cdaa  (unknown)
    @     0x7f3ac479cce4  (unknown)
    @     0x7f3ac479c6e6  (unknown)
    @     0x7f3ac479f687  (unknown)
    @     0x7f3ac4f7c3ab  caffe::DetectionEvaluateLayer<>::Reshape()
    @     0x7f3ac4fa153c  caffe::Net<>::Init()
    @     0x7f3ac4fa23b5  caffe::Net<>::Net()
    @     0x7f3ac504d042  caffe::Solver<>::InitTestNets()
    @     0x7f3ac504d89d  caffe::Solver<>::Init()
    @     0x7f3ac504db8a  caffe::Solver<>::Solver()
    @     0x7f3ac4fcb0c6  caffe::Creator_RMSPropSolver<>()
    @           0x40fbee  caffe::SolverRegistry<>::CreateSolver()
    @           0x408c44  train()
    @           0x4065ac  main
    @     0x7f3ac2ff3f45  (unknown)
    @           0x406eb3  (unknown)
    @              (nil)  (unknown)
Aborted (core dumped)

如何解决上述错误?谢谢

标签: opencvcaffeubuntu-20.04

解决方案


推荐阅读