yolo fastest中输出结果解析

本文介绍了YOLO目标检测算法中的关键函数实现,包括计算预测框的数量、获取预测框中各类别的概率及从输出中解析预测框等。通过具体代码示例展示了YOLO算法的工作流程。
//预测输出中置信度超过阈值的 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;
              }
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值