read_data.py 文件源码

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

项目:human-pose-estimation-by-deep-learning 作者: HYPJUDY 项目源码 文件源码
def _random_flip_lr(self, images, labels):
        if(images.shape[0] != labels.shape[0]):
            raise Exception("Batch size Error.")
        rand_u = np.random.uniform(0.0, 1.0, images.shape[0])
        rand_cond = rand_u > 0.5

        o_images = np.zeros_like(images)
        o_labels = np.zeros_like(labels)

        for idx in xrange(images.shape[0]):
            condition = rand_cond[idx]
            if condition:
                # "flip"
                o_images[idx] = np.fliplr(images[idx])
                o_labels[idx, ::2] = self.float_max - labels[idx, ::2]
                o_labels[idx, 1::2] = labels[idx, 1::2]
            else:
                # "origin"
                o_images[idx] = images[idx]
                o_labels[idx] = labels[idx]

        return o_images, o_labels
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号