【问题标题】:Segmentation fault (core dumped) when using YOLOv3 from pjreddie从 pjreddie 使用 YOLOv3 时出现分段错误(核心转储)
【发布时间】:2019-12-06 04:18:26
【问题描述】:

我想使用YOLOv3 算法进行检测。我正在使用安装了 Linux 的英特尔 DE10 Nano FPGA 板。当我构建 YOLOv3(来自原始源)并运行它时,我收到错误“分段错误(核心转储)”。我做了很多研究,但没有一个有助于解决这个问题。

我使用了预先构建的权重和配置文件,即我运行了以下命令

./darknet detect cfg/yolov3-tiny.cfg yolov3-tiny.weights data/dog.jpg

但出现上述错误。但同样的事情在我的计算机和其他几个计算机上运行时没有任何问题,但在我的开发板上却没有。 然后我开始调试(使用大量 printf 语句)“python”目录中“darknet.py”中的代码,发现错误位于

"yolo_layer.c" file
 
line.no.336-> "dets[count].prob[j] = (prob > thresh) ? prob : 0;"
 
in "get_yolo_detections" function.

我该如何解决这个问题?我已经按照函数和文件来查看错误来自哪里。

int get_yolo_detections(layer l, int w, int h, int netw, int neth, float thresh, int *map, int relative, detection *dets)
{
    int i,j,n;
    float *predictions = l.output;
    if (l.batch == 2) avg_flipped_yolo(l);
    int count = 0;
    for (i = 0; i < l.w*l.h; ++i){
        int row = i / l.w;
        int col = i % l.w;
        for(n = 0; n < l.n; ++n){
            int obj_index  = entry_index(l, 0, n*l.w*l.h + i, 4);
            float objectness = predictions[obj_index];
            if(objectness <= thresh) continue;
            int box_index  = entry_index(l, 0, n*l.w*l.h + i, 0);
            dets[count].bbox = get_yolo_box(predictions, l.biases, l.mask[n], box_index, col, row, l.w, l.h, netw, neth, l.w*l.h);
            dets[count].objectness = objectness;
            dets[count].classes = l.classes;
            for(j = 0; j < l.classes; ++j){
                int class_index = entry_index(l, 0, n*l.w*l.h + i, 4 + 1 + j);
                float prob = objectness*predictions[class_index];

                //|||||||error in below line||||||||
                dets[count].prob[j] = (prob > thresh) ? prob : 0;
                //^^--error in the above line(got from debugging)

            }
            ++count;
        }
    }
    correct_yolo_boxes(dets, count, w, h, netw, neth, relative);
    return count;
}

【问题讨论】:

    标签: c image-processing segmentation-fault fpga yolo


    【解决方案1】:

    终于找到了问题和解决方案。 加载权重时,问题出在“src/parser.c”文件中。从“.weights”文件加载权重的函数依赖于底层机器架构(32 位或 64 位)。训练时创建的 .weights 文件的大小为 64 位,因为训练是在 64 位机器上完成的,因为像 jetson、raspberry pi、de10 Nano 等设备具有 32 位架构,它们将权重加载为权重文件中的 32 位格式。

    因此存在兼容性问题(重量不跨平台)。

    要解决此问题,请更改

    fwrite(net->seen, sizeof(size_t), 1, fp);// in save_weights_upto() function
    

    到(在第 1024 行 - )

    fwrite(net->seen, 8, 1, fp);
    

    和---------------------------------------------- ---------------------

    fread(net->seen, sizeof(size_t), 1, fp);//in load_weights_upto() function
    

    到(在第 1237 行)

    fread(net->seen, 8, 1, fp);
    

    【讨论】:

      猜你喜欢
      • 2021-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多