utils_tf.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:blitznet 作者: dvornikita 项目源码 文件源码
def zoomout(image, gt_bboxes, params):
    X_out = tf.random_uniform([], 1.05, params['X_out'])
    h, w, _ = tf.unstack(tf.to_float(tf.shape(image)))
    zoomout_color = params['zoomout_color']+[0]

    bg_color = tf.constant(zoomout_color, dtype=tf.float32)
    x_shift = tf.random_uniform([], 0, (X_out - 1) * w)
    y_shift = tf.random_uniform([], 0, (X_out - 1) * h)
    x2_shift = (X_out - 1) * w - x_shift
    y2_shift = (X_out - 1) * h - y_shift
    # somewhat hacky solution to pad with MEAN_COLOR
    # tf.pad does not support custom constant padding unlike numpy
    image -= bg_color
    image = tf.pad(image, tf.to_int32([[y_shift, y2_shift], [x_shift, x2_shift], [0, 0]]))
    image += bg_color

    gt_x, gt_y, gt_w, gt_h = tf.unstack(gt_bboxes, axis=1)
    gt_bboxes = tf.stack([gt_x + x_shift/w,
                          gt_y + y_shift/h,
                          gt_w, gt_h], axis=1)/X_out
    return image, gt_bboxes
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号