【问题标题】:How can I edit or remove the bounding box label text in YOLO (V4)?如何在 YOLO (V4) 中编辑或移除边界框标签文本?
【发布时间】:2021-06-22 23:37:22
【问题描述】:

我想编辑边界框标签以只显示检测概率而不显示类别标签,我该怎么做?

我在 darknet/src 中找到了一个名为 image.c 的文件,我认为这是我需要进行编辑的地方。 但是其中有多个似乎与此任务相关的功能,我不确定要编辑哪个,以及如何编辑以获得我想要的。 image.c 中的代码很长,因此请参考this 链接(官方暗网回购),我所指的代码是可用的。

我尝试在第 465 行编辑函数 void draw_detections,只需将第 511 行的代码更改为 printf("%s: %.0f%%", " ", prob * 100);,运行 !make 命令,但标签仍然存在于检测中。

【问题讨论】:

    标签: computer-vision object-detection yolo bounding-box yolov4


    【解决方案1】:

    您在项目中使用 alexyAB 模型。转到 image_opencv.cpp 文件并找到 draw_detections_cv_v3 函数,然后找到此行:

     strcat(labelstr, names[j]);
    

    改为:

    strcat(labelstr, "");
    

    【讨论】:

    • 在函数内部进行了建议的更改,运行了 !make 命令,但仍显示类标签。这没有做任何事情。 (给定函数中有两行'strcat(labelstr,names[j]);',我都改了)
    【解决方案2】:

    终于找到了方法:

    找到文件darknet/src/image.c

    删除 436行代码

    strcat(labelstr, names[selected_detections[i].best_class]);
    

    从第 441 行到第 446 行

    for (j = 0; j < classes; ++j) { 
        if (selected_detections[i].det.prob[j] > thresh && j != selected_detections[i].best_class) { 
            strcat(labelstr, ", "); 
            strcat(labelstr, names[j]); 
        } 
    } 
    

    确保在项目中重建暗网(!make

    注意:如果再次克隆暗网存储库,这些更改将被删除。

    【讨论】:

      猜你喜欢
      • 2019-12-09
      • 2021-04-04
      • 2018-10-31
      • 2018-08-13
      • 2021-08-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-04
      • 2017-11-16
      相关资源
      最近更新 更多