textboxes 代码中的几个重要变量

1 anchors

核心代码

def textbox_anchor_one_layer(img_shape,
								feat_size,
								ratios,
								scale,
								sizes,
								offset = 0.5,
								dtype=np.float32):
		"""
		#这个是用来产生一层的anchor
		#当img_shape [300,300]
		#feat_size=(30,60) 只是下面的第一层对应的述职
		anchor_sizes=[(30., 60.),
			  (60., 114.),
			  (114., 168.),
			  (168., 222.),
			  (222., 276.),
			  (276., 330.)],
		ratios = (1,2,3,5,7,10)
		sizes =[38,38] 第一层映射的map尺寸 总共有[(38,38)(19,19)(10,10)(5,5)(3,3)(1,1)]6层
		scale没用到
		"""
		y, x = np.mgrid[0:feat_size[0], 0:feat_size[1]]

		y = (y.astype(dtype) + offset) / feat_size[0] 
		x = (x.astype(dtype) + offset) / feat_size[1]
		y_offset = y + offset/feat_size[0]
		x_offset = x
		x_out = np.stack((x, x_offset), -1)
		y_out = np.stack((y, y_offset), -1)
		y_out = np.expand_dims(y_out, axis=-1)
		x_out = np.expand_dims(x_out, axis=-1)


		numofanchor = len(ratios) + 1
		h = np.zeros((numofanchor, ), dtype=dtype)
		w = np.zeros((numofanchor, ), dtype=dtype)

		for i, r in enumerate(ratios):
				h[i] = sizes[0] / img_shape[0] / math.sqrt(r)
				w[i] = sizes[0] / img_shape[1] * math.sqrt(r)
		h[i] = sizes[0] / img_shape[0] / 3.
		w[i] = sizes[0] / img_shape[1] * 1.6
		if feat_size[0] == 38:
			h[i+1] = sizes[0] / img_shape[0] / 4.
			w[i+1] = sizes[0] / img_shape[1] / 2.
		else:
			h[i+1] = sizes[0] / img_shape[0] 
			w[i+1] = sizes[0] / img_shape[1] * 2
 		return y_out, x_out, h, w
		"""
		y_out  [38,38,2,1]表示y轴(0维)上坐标值对应的比值,2表示两部分,一部分没有偏移,一部分+0.5/feat_size[0]
		x_out  [38,38,2,1]表示x轴(1维)上坐标值对应的比值,2表示两部分的值一样
		h = [7] #表示7种高度
		w = [7] #表示7种宽度
		"""

一共有6层,所以根据下面的代码计算anchor

def textbox_achor_all_layers(img_shape,
													 layers_shape,
													 anchor_ratios,
													 scales,
													 anchor_sizes,
													 offset=0.5,
													 dtype=np.float32):
		"""
		Compute anchor boxes for all feature layers.
		"""
		layers_anchors = []
		for i, s in enumerate(layers_shape):
				anchor_bboxes = textbox_anchor_one_layer(img_shape, s,
																								 anchor_ratios,
																								 scales[i],
																								 anchor_sizes[i],
																								 offset=offset, dtype=dtype)
				layers_anchors.append(anchor_bboxes)
		return layers_anchors

anchors 的值含有6个值得list

[

([38,38,2,1],[38,38,2,1],[7],[7]) ,              #其中的数值代表结构

([19,19,2,1],[19,19,2,1],[7],[7])

([10,10,2,1],[10,10,2,1],[7],[7])

([5,5,2,1],[5,5,2,1],[7],[7])

([3,3,2,1],[3,3,2,1],[7],[7])

([1,1,2,1],[1,1,2,1],[7],[7])

]

2 图像处理后的image, labels, bboxes
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值