data_class.py 文件源码

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

项目:traffic_video_analysis 作者: polltooh 项目源码 文件源码
def decode(self, filename, distort_data, whiten_data = True):
        """distort: random distort the iamge"""
        image_tensor = tf.read_file(filename)
        image_tensor = self.decode_fun(image_tensor, channels = self.channels, ratio = self.ratio)
        image_tensor = tf.image.convert_image_dtype(image_tensor, tf.float32)
        image_tensor = tf.image.resize_images(image_tensor, 
                                        [self.shape[0] + self.offset, self.shape[1] + self.offset])

        if distort_data:
                # it will crop in the function
                image_tensor = self.distort_op(image_tensor)
        else:
                image_tensor = tf.image.resize_image_with_crop_or_pad(image_tensor,
                                                                                self.shape[0], self.shape[1])
        if whiten_data:
                # Subtract off the mean and divide by the variance of the pixels.
                image_tensor = tf.image.per_image_whitening(image_tensor)

        return image_tensor
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号