pascalvoc_segnet_input.py 文件源码

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

项目:woipv 作者: Panaetius 项目源码 文件源码
def __put_bboxes_on_image(self, images, boxes, scale_x, scale_y):

        output = []

        polys1 = tf.sparse_tensor_to_dense(polys, default_value=-1)
        mask = bboxes1 >= 0
        bboxes1 = tf.boolean_mask(bboxes1, mask)
        bboxes = tf.reshape(bboxes1, [1, -1, 4])

        bboxes = bboxes * [[scale_y, scale_x, scale_y, scale_x]]
        shape = tf.shape(bboxes)
        bboxes = self.__clip_bboxes(tf.reshape(bboxes, [-1, 4]), 1.0, 1.0)
        y, x, h, w = tf.split(bboxes, 4, axis=1)
        bboxes = tf.concat([1.0 - (y + h / 2.0) - 0.001, x - w / 2.0 - 0.001,
                            1.0 - (y - h / 2.0) + 0.001,
                            x + w / 2.0 + 0.001],
                            axis=1)
        bboxes = tf.reshape(bboxes, shape)
        bboxes = tf.clip_by_value(bboxes, 0.0, 1.0)

        image = tf.cond(tf.size(bboxes1) > 0,
                        lambda: tf.image.draw_bounding_boxes(images,
                                                            bboxes),
                        lambda: images)

        return image
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号