如何在 YOLO (V4) 中编辑或删除边界框标签文本?

问题描述

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

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

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

解决方法

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

 strcat(labelstr,names[j]);

改为:

strcat(labelstr,"");
,

终于找到方法了:

找到文件 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

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