dcgan_var2.py 文件源码

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

项目:deeplearning 作者: zxjzxj9 项目源码 文件源码
def _process(self):

        def img_process(fn):
            img = tf.image.decode_image(tf.read_file(fn))
            cropped = tf.image.resize_image_with_crop_or_pad(img, tf.app.flags.FLAGS.crop_height, tf.app.flags.FLAGS.crop_width)
            new_img = tf.image.resize_images(cropped, (tf.app.flags.FLAGS.target_height, tf.app.flags.FLAGS.target_width), method = 
                                             tf.image.ResizeMethod.AREA)
            return fn, new_img

        filenames = tf.constant(glob.glob(os.path.join(self.src_dir,"*")))
        dataset = tf.data.Dataset.from_tensor_slices((filenames, ))
        dataset = dataset.map(img_process)
        dataset = dataset.shuffle(buffer_size=10000)
        dataset = dataset.batch(tf.app.flags.FLAGS.batch_size)
        dataset = dataset.repeat(tf.app.flags.FLAGS.epochs)

        iterator = dataset.make_one_shot_iterator()

        labels, imgs = iterator.get_next()
        return labels, imgs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号