2019-01-14

此外,计算bbox误差时,不是比较四个角的坐标,而是tx,ty,tw,th,具体计算如下:

预测的中心点和长宽值

明明只需要log,    却除以了log(2),转换底,因为c++里面的log是默认以e为底,然而e不好打出来,另外的   fit_ratio是为了让值显得大一些,才进行的。


train中

void CHECK_IOU(Anchor<Dtype>& anchor, const std::vector<Box<Dtype>> &GT_Boxes){

int target_num = GT_Boxes.size();

Dtype area1 = anchor.width * anchor.height;

Dtype maxoverlap = 0.f;

int index = -1;

for (int i = 0; i < target_num; i++) {

const Box<Dtype> &gt_box = GT_Boxes[i];

Dtype x0 = std::max(anchor.x_ctr - anchor.width / 2, gt_box.x0);

Dtype y0 = std::max(anchor.y_ctr - anchor.height / 2, gt_box.y0);

Dtype x1 = std::min(anchor.x_ctr + anchor.width / 2, gt_box.x0 + gt_box.width);

Dtype y1 = std::min(anchor.y_ctr + anchor.height / 2, gt_box.y0 + gt_box.height);

Dtype area = (x1 - x0 + 1) * (y1 - y0 + 1);

if (x1 - x0 + 1 < 0 || y1 - y0 + 1 < 0){

continue;

}

Dtype area2 = gt_box.width * gt_box.height;

Dtype Overlap = area / (area1 + area2 - area);

if (Overlap > maxoverlap) {

maxoverlap = Overlap;

index = i;

}

}

anchor.overlap = maxoverlap;

if (maxoverlap > Part_overlap) {

const Box<Dtype> &box = GT_Boxes[index];

anchor.name = box.name;

if (maxoverlap > Pos_overlap) {

anchor.isobject = 2;

}

else {

anchor.isobject = 1;

}

anchor.Tar[0] = (box.x0 + box.width / 2 - anchor.x_ctr) / anchor.width;

anchor.Tar[1] = (box.y0 + box.height / 2 - anchor.y_ctr) / anchor.height;

anchor.Tar[2] = std::log(box.width / anchor.width) / std::log(2) * fit_ratio;

anchor.Tar[3] = std::log(box.height / anchor.height) / std::log(2) * fit_ratio;

}

else {

anchor.isobject = 0;

caffe::caffe_memset(4 * sizeof(Dtype), 0, anchor.Tar);

}

if (LabelIndex.count(anchor.name)) {

anchor.cls = LabelIndex.find(anchor.name)->second;

}

}

test中

微调box

template < typename Dtype >

inline void ReassignBox(Box &box, const Anchor<Dtype> &anchor,

Dtype x_ctr_off, Dtype y_ctr_off, Dtype w_off, Dtype h_off){

box.width = std::pow(2, w_off / fit_ratio) * anchor.width;

box.height = std::pow(2, h_off / fit_ratio) * anchor.height;

box.x0 = x_ctr_off * anchor.width + anchor.x_ctr - box.width / 2;

box.y0 = y_ctr_off * anchor.height + anchor.y_ctr - box.height / 2;

}

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 目录faster rcnn论文备注caffe代码框架简介faster rcnn代码分析后记 faster rcnn...
    db24cc阅读 13,199评论 2 12
  • //动态创建表格---JS API视图 <!DOCTYPE html> title * { ma...
    CtrlAltShift阅读 1,124评论 0 0
  • 七、物质宇宙的大小及年龄 1、从物质粒子的大小看微观宇宙有多小 ⑴物质由分子组成 在宇宙中的一切物质均由分子组成。...
    宇宙形成阅读 4,463评论 0 0
  • 如何救一个不会游泳的人? 换个话题,也就是说一个人如何“停”下来? 有个故事,一个不会游泳的人掉在水中扑腾,越挣扎...
    天之心语阅读 838评论 0 2
  • 初次看到这本书名字,以为是什么禅学,看到豆瓣评分便和其他书一起,让它搭着顺丰车到了家里,被搁置在角落,然后在某一天...
    一路有你ing阅读 3,359评论 0 0