proposal.py 文件源码

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

项目:tf-image-interpreter 作者: ThoughtWorksInc 项目源码 文件源码
def _clip_boxes(self, boxes, image):
    height = tf.shape(image)[1]
    width = tf.shape(image)[2]
    # TODO: what TF will do with tensors that will not be used anymore?
    x1_over_0 = tf.reshape(tf.maximum(tf.minimum(boxes[:, 0::4], tf.cast(width - 1, tf.float32)), 0), (-1,))
    y1_over_0 = tf.reshape(tf.maximum(tf.minimum(boxes[:, 1::4], tf.cast(height - 1, tf.float32)), 0), (-1,))
    x2_below_width = tf.reshape(tf.maximum(tf.minimum(boxes[:, 2::4], tf.cast(width - 1, tf.float32)), 0), (-1,))
    y2_below_height = tf.reshape(tf.maximum(tf.minimum(boxes[:, 3::4], tf.cast(height - 1, tf.float32)), 0), (-1,))
    boxes = tf.pack(
      [x1_over_0,  # x1 >= 0
       y1_over_0,  # y1 >= 0
       x2_below_width,  # x2 < im_shape[1]
       y2_below_height],  # y2 < im_shape[0]
      axis=1
    )
    return boxes

  # bbox_transform_inv
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号