def _add_jittered_boxes(rois, scores, batch_inds, gt_boxes, jitter=0.1):
ws = gt_boxes[:, 2] - gt_boxes[:, 0]
hs = gt_boxes[:, 3] - gt_boxes[:, 1]
shape = tf.shape(gt_boxes)[0]
jitter = tf.random_uniform([shape, 1], minval = -jitter, maxval = jitter)
jitter = tf.reshape(jitter, [-1])
ws_offset = ws * jitter
hs_offset = hs * jitter
x1s = gt_boxes[:, 0] + ws_offset
x2s = gt_boxes[:, 2] + ws_offset
y1s = gt_boxes[:, 1] + hs_offset
y2s = gt_boxes[:, 3] + hs_offset
boxes = tf.concat(
values=[
x1s[:, tf.newaxis],
y1s[:, tf.newaxis],
x2s[:, tf.newaxis],
y2s[:, tf.newaxis]],
axis=1)
new_scores = tf.ones([shape], tf.float32)
new_batch_inds = tf.zeros([shape], tf.int32)
return tf.concat(values=[rois, boxes], axis=0), \
tf.concat(values=[scores, new_scores], axis=0), \
tf.concat(values=[batch_inds, new_batch_inds], axis=0)
评论列表
文章目录