//预测输出中置信度超过阈值的 box 个数
int yolo_num_detections(layer l, float thresh)
{
int i, n;
int count = 0;
for (i = 0; i < l.w*l.h; ++i){
for(n = 0; n < l.n; ++n){
//获得置信度偏移位置
int obj_index = entry_index(l, 0, n*l.w*l.h + i, 4);
//置信度超过阈值
if(l.output[obj_index] > thresh){
++count;
}
}
}
return count;
}
//获取预测输出bbox中各个类别的概率
void get_yolo_class_probability(layer l, float thresh)
{
int i, j, n;
float *predictions = l.output;
for (i = 0; i < l.w*l.h; ++i)
{
for(n = 0; n < l.n; ++n)
{
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 = predictions[class_index];// 某一个框中某一个类别的概率
cout<<"prob:"<<prob<<endl;
}
}
}
}