CycleGAN--应用于图像风格迁移


包含,CycleGAN的代码,文档以及论文,讲解详细,有需要者不可放过。
资源截图
代码片段和文件信息
from __future__ import absolute_import division print_function

import tensorflow as tf


def image_batch(image_paths batch_size load_size=286 crop_size=256 channels=3 shuffle=True
                num_threads=4 min_after_dequeue=100 allow_smaller_final_batch=False):
    “““ for jpg and png files “““
    # queue and reader
    img_queue = tf.train.string_input_producer(image_paths shuffle=shuffle)
    reader = tf.WholeFileReader()

    # preprocessing
    _ img = reader.read(img_queue)
    img = tf.image.decode_image(img channels=3)
    ‘‘‘
    tf.image.random_flip_left_right should be used before tf.image.resize_images
    because tf.image.decode_image reutrns a tensor without shape which makes
    tf.image.resize_images collapse. Maybe it‘s a bug!
    ‘‘‘
    img = tf.image.random_flip_left_right(img)
    img = tf.image.resize_images(img [load_size load_size])
    img = tf.random_crop(img [crop_size crop_size channels])
    img = tf.cast(img tf.float32) / 127.5 - 1

    # batch
    if shuffle:
        capacity = min_after_dequeue + (num_threads + 1) * batch_size
        img_batch = tf.train.shuffle_batch([img]
                                           batch_size=batch_size
                                           capacity=capacity
                                           min_after_dequeue=min_after_dequeue
                                           num_threads=num_threads
                                           allow_smaller_final_batch=allow_smaller_final_batch)
    else:
        img_batch = tf.train.batch([img]
                                   batch_size=batch_size
                                   allow_smaller_final_batch=allow_smaller_final_batch)
    return img_batch len(image_paths)


class ImageData:

    def __init__(self session image_paths batch_size load_size=286 crop_size=256 channels=3 shuffle=True
                 num_threads=4 min_after_dequeue=100 allow_smaller_final_batch=False):
        self.sess = session
        self.img_batch self.img_num = image_batch(image_paths batch_size load_size crop_size channels shuffle
                                                   num_threads min_after_dequeue allow_smaller_final_batch)

    def __len__(self):
        return self.img_num

    def batch_ops(self):
        return self.img_batch

    def batch(self):
        return self.sess.run(self.img_batch)

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-10 10:28  CycleGAN-风格迁移
     目录           0  2018-09-08 20:49  CycleGAN-风格迁移PPT及PDF
     文件    47225034  2018-09-08 20:49  CycleGAN-风格迁移PPT及PDFCycleGAN复现指南.pdf
     文件     8495657  2018-09-08 20:40  CycleGAN-风格迁移PPT及PDFCycleGAN复现指南.pptx
     文件     2737562  2018-09-08 20:38  CycleGAN-风格迁移Unpaired Image-to-Image Translation using Cycle-Consistent Adversarial Networks.pdf
     目录           0  2018-09-10 10:29  CycleGAN-风格迁移源码及数据
     文件        2411  2018-09-08 20:49  CycleGAN-风格迁移源码及数据data.py
     文件        6287  2018-09-08 20:49  CycleGAN-风格迁移源码及数据image_utils.py
     文件        3090  2018-09-08 20:49  CycleGAN-风格迁移源码及数据models.py
     文件        2844  2018-09-08 20:49  CycleGAN-风格迁移源码及数据ops.py
     文件        2496  2018-09-08 20:49  CycleGAN-风格迁移源码及数据 est.py
     文件        7606  2018-09-08 20:49  CycleGAN-风格迁移源码及数据 rain.py
     文件        1760  2018-09-08 20:50  CycleGAN-风格迁移源码及数据utils.py

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件举报,一经查实,本站将立刻删除。

发表评论

评论列表(条)