anchor_target_layer中的bounding regression
在anchor_target层,这两行是计算bounding regression代码:
bbox_targets = np.zeros((len(inds_inside), 4), dtype=np.float32)
bbox_targets = _compute_targets(anchors, gt_boxes[argmax_overlaps, :])
def _compute_targets(ex_rois, gt_rois):
"""Compute bounding-box regression targets for an image.""" assert ex_rois.shape[0] == gt_rois.shape[0]
assert ex_rois.shape[1] == 4
assert gt_rois.shape[1] == 5 return bbox_transform(ex_rois, gt_rois[:, :4]).astype(np.float32, copy=False)
以下是bounding regression的计算公式:
def bbox_transform(ex_rois, gt_rois):
ex_widths = ex_rois[:, 2] - ex_rois[:, 0] + 1.0
ex_heights = ex_rois[:, 3] - ex_rois[:, 1] + 1.0
ex_ctr_x = ex_rois[:, 0] + 0.5 * ex_widths
ex_ctr_y = ex_rois[:, 1] + 0.5 * ex_heights gt_widths = gt_rois[:, 2] - gt_rois[:, 0] + 1.0
gt_heights = gt_rois[:, 3] - gt_rois[:, 1] + 1.0
gt_ctr_x = gt_rois[:, 0] + 0.5 * gt_widths
gt_ctr_y = gt_rois[:, 1] + 0.5 * gt_heights targets_dx = (gt_ctr_x - ex_ctr_x) / ex_widths
targets_dy = (gt_ctr_y - ex_ctr_y) / ex_heights
targets_dw = np.log(gt_widths / ex_widths)
targets_dh = np.log(gt_heights / ex_heights) targets = np.vstack(
(targets_dx, targets_dy, targets_dw, targets_dh)).transpose()
return targets
argmax_overlaps是每个anchor对应最大overlap的gt_boxes的下标,所以bbox_targets存储的是anchor和最大overlap的gt之间的bouding regression。
因为all_anchors裁减掉了2/3左右,仅仅保留在图像内的anchor。利用_unmap函数复原作为这一层的一个输出,并reshape成相应的格式,输出到rpn_loss_bbox。
rpn_loss_bbox的另一个输入是由特征提取出的4个坐标变换。
是一个feature map(即特征向量)。ti*是anchor和gt bounding box regression的结果(即△x,△y,△w,△h)。这样也可以看出rpn_bbox_pred不是直接生成的roi坐标,而是feature map。
anchor_target_layer中的bounding regression的更多相关文章
- 目标检测中的bounding box regression
目标检测中的bounding box regression 理解:与传统算法的最大不同就是并不是去滑窗检测,而是生成了一些候选区域与GT做回归.
- 解读SSD中的Default box(Prior Box)
1:SSD更具体的框架如下: 2: Prior Box 缩进在SSD中引入了Prior Box,实际上与anchor非常类似,就是一些目标的预选框,后续通过softmax分类+bounding box ...
- Object-Detection中常用的概念解析
常用的Region Proposal Selective Search Edge Boxes Softmax-loss softmax-loss层和softmax层计算大致是相同的,softmax是一 ...
- SparkMLlib之 logistic regression源码分析
最近在研究机器学习,使用的工具是spark,本文是针对spar最新的源码Spark1.6.0的MLlib中的logistic regression, linear regression进行源码分析,其 ...
- 在matlab中实现线性回归和logistic回归
本文主要讲解在matlab中实现Linear Regression和Logistic Regression的代码,并不涉及公式推导.具体的计算公式和推导,相关的机器学习文章和视频一大堆,推荐看Andr ...
- Linear Regression总结
转自:http://blog.csdn.net/dongtingzhizi/article/details/16884215 Linear Regression总结 作者:洞庭之子 微博:洞庭之子-B ...
- Logistic Regression总结
转自:http://blog.csdn.net/dongtingzhizi/article/details/15962797 Logistic回归总结 作者:洞庭之子 微博:洞庭之子-Bing (20 ...
- Android中蓝牙的基本使用----BluetoothAdapter类简介
天气逐渐热了,自己也越来越懒了,虽然看着了很多东西,解决了很多问题,有些收获却不想写着.主要有一下两方面原因: 第一.以前写的一些关于Android知识的Blog,都是在学习过程中发现网络上没有相关知 ...
- rcnn ->fast rcnn->faster rcnn物体检测论文
faster rcnn中的rpn网络: 特征可以看做一个尺度51*39的256通道图像,对于该图像的每一个位置,考虑9个可能的候选窗口:三种面积{1282,2562,5122}×三种比例{1:1,1: ...
随机推荐
- bash: crontab: command not found
操作步骤 1. 确认crontab是否安装: 执行 crontab 命令如果报 command not found,就表明没有安装 2. 安装 crontab 执行 yum install -y vi ...
- Ruby: 获取IE的一些信息(其实应用AutoIt脚本本身,获取这些信息更加简单)
require'win32/registry' hkey_local_machine=Win32::Registry::HKEY_LOCAL_MACHINE defgetKeyValue(hive, ...
- 《StackGAN: Text to Photo-realistic Image Synthesis with Stacked GAN》论文笔记
出处:arxiv 2016 尚未出版 Motivation 根据文字描述来合成相片级真实感的图片是一项极具挑战性的任务.现有的生成手段,往往只能合成大体的目标,而丢失了生动的细节信息.StackGAN ...
- UI:单例的写法
单例设计模式 参考 UIApplication sharedApplocation 详细解释 :参考 通讯录的helper 类的读取本地plist 文件的时候,使用的单例单例的要点有三个:一个类只能有 ...
- LA 4670 Dominating Patterns (AC自动机)
题意:给定一个一篇文章,然后下面有一些单词,问这些单词在这文章中出现过几次. 析:这是一个AC自动机的裸板,最后在匹配完之后再统计数目就好. 代码如下: #pragma comment(linker, ...
- Ruby Proc类
Proc类 生成 Proc.new() {...} proc {...} 注,代码块参数带用 |..., *array| 获得后续参数的数组 lamda {...} call呼出时会 ...
- bzoj 1567: [JSOI2008]Blue Mary的战役地图【二分+hash】
二维哈希+二分 说是二维,其实就是先把列hash了,然后再用列的hash值hash行,这样可以O(n)的计算一个正方形的hash值,然后二分边长,枚举左上角点的坐标然后hash判断即可 只要base选 ...
- poj 2398 Toy Storage【二分+叉积】
二分点所在区域,叉积判断左右 #include<iostream> #include<cstdio> #include<cstring> #include<a ...
- Luogu P1273 有限电视网【树形Dp/树形背包】
题目描述 某收费有线电视网计划转播一场重要的足球比赛.他们的转播网和用户终端构成一棵树状结构,这棵树的根结点位于足球比赛的现场,树叶为各个用户终端,其他中转站为该树的内部节点. 从转播站到转播站以及从 ...
- yml文件教程
地址:http://www.ruanyifeng.com/blog/2016/07/yaml.html 原来三个横线(---)是用来区分多个文件的,像下面就是指定了两个配置. spring: appl ...