资源简介
cyclegan图像转换压缩包,橘子苹果数据集及相关项目代码,可直接运行。

代码片段和文件信息
import tensorflow as tf
import random
import os
try:
from os import scandir
except ImportError:
# Python 2 polyfill module
from scandir import scandir
FLAGS = tf.flags.FLAGS
tf.flags.DEFINE_string(‘X_input_dir‘ ‘data/apple2orange/trainA‘
‘X input directory default: data/apple2orange/trainA‘)
tf.flags.DEFINE_string(‘Y_input_dir‘ ‘data/apple2orange/trainB‘
‘Y input directory default: data/apple2orange/trainB‘)
tf.flags.DEFINE_string(‘X_output_file‘ ‘data/tfrecords/apple.tfrecords‘
‘X output tfrecords file default: data/tfrecords/apple.tfrecords‘)
tf.flags.DEFINE_string(‘Y_output_file‘ ‘data/tfrecords/orange.tfrecords‘
‘Y output tfrecords file default: data/tfrecords/orange.tfrecords‘)
def data_reader(input_dir shuffle=True):
“““Read images from input_dir then shuffle them
Args:
input_dir: string path of input dir e.g. /path/to/dir
Returns:
file_paths: list of strings
“““
file_paths = []
for img_file in scandir(input_dir):
if img_file.name.endswith(‘.jpg‘) and img_file.is_file():
file_paths.append(img_file.path)
if shuffle:
# Shuffle the ordering of all image files in order to guarantee
# random ordering of the images with respect to label in the
# saved TFRecord files. Make the randomization repeatable.
shuffled_index = list(range(len(file_paths)))
random.seed(12345)
random.shuffle(shuffled_index)
file_paths = [file_paths[i] for i in shuffled_index]
return file_paths
def _int64_feature(value):
“““Wrapper for inserting int64 features into Example proto.“““
if not isinstance(value list):
value = [value]
return tf.train.Feature(int64_list=tf.train.Int64List(value=value))
def _bytes_feature(value):
“““Wrapper for inserting bytes features into Example proto.“““
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
def _convert_to_example(file_path image_buffer):
“““Build an Example proto for an example.
Args:
file_path: string path to an image file e.g. ‘/path/to/example.JPG‘
image_buffer: string JPEG encoding of RGB image
Returns:
Example proto
“““
file_name = file_path.split(‘/‘)[-1]
example = tf.train.Example(features=tf.train.Features(feature={
‘image/file_name‘: _bytes_feature(tf.compat.as_bytes(os.path.basename(file_name)))
‘image/encoded_image‘: _bytes_feature((image_buffer))
}))
return example
def data_writer(input_dir output_file):
“““Write data to tfrecords
“““
file_paths = data_reader(input_dir)
# create tfrecords dir if not exists
output_dir = os.path.dirname(output_file)
try:
os.makedirs(output_dir)
except os.error as e:
pass
images_num = len(file_paths)
# dump to tfrecords file
writer = tf.python_io.TFRecordWriter(output_file)
for i in range(len(file_paths)):
file_path = file_paths[i]
with tf.gfile.FastGFile(file_path ‘rb‘)
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2018-02-19 13:14 CycleGAN-TensorFlow-master\
文件 1134 2018-02-19 13:14 CycleGAN-TensorFlow-master\.gitignore
文件 1064 2018-02-19 13:14 CycleGAN-TensorFlow-master\LICENSE
文件 1462 2018-02-19 13:14 CycleGAN-TensorFlow-master\Makefile
文件 5249 2018-02-19 13:14 CycleGAN-TensorFlow-master\README.md
文件 3508 2018-02-19 13:14 CycleGAN-TensorFlow-master\build_data.py
文件 1575 2018-02-19 13:14 CycleGAN-TensorFlow-master\discriminator.py
文件 891 2018-02-19 13:14 CycleGAN-TensorFlow-master\download_dataset.sh
文件 2427 2018-02-19 13:14 CycleGAN-TensorFlow-master\export_graph.py
文件 2346 2018-02-19 13:14 CycleGAN-TensorFlow-master\generator.py
文件 1696 2018-02-19 13:14 CycleGAN-TensorFlow-master\inference.py
文件 6802 2018-02-19 13:14 CycleGAN-TensorFlow-master\model.py
文件 7553 2018-02-19 13:14 CycleGAN-TensorFlow-master\ops.py
文件 3092 2018-02-19 13:14 CycleGAN-TensorFlow-master\reader.py
目录 0 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\
文件 31383 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_apple2orange_1.jpg
文件 30087 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_apple2orange_2.jpg
文件 30996 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_apple2orange_3.jpg
文件 33407 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_apple2orange_4.jpg
文件 29567 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_orange2apple_1.jpg
文件 35564 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_orange2apple_2.jpg
文件 35508 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_orange2apple_3.jpg
文件 24023 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\fake_orange2apple_4.jpg
文件 52036 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_apple2orange_1.jpg
文件 37790 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_apple2orange_2.jpg
文件 46289 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_apple2orange_3.jpg
文件 55345 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_apple2orange_4.jpg
文件 50803 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_orange2apple_1.jpg
文件 57115 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_orange2apple_2.jpg
文件 55258 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_orange2apple_3.jpg
文件 38452 2018-02-19 13:14 CycleGAN-TensorFlow-master\samples\real_orange2apple_4.jpg
............此处省略3个文件信息
- 上一篇:DS1302驱动程序.zip
- 下一篇:STM32接入OneNET代码
相关资源
- Iris数据集分类,查看几种分类方法的
- 陈强stata数据集
- 基于pytorch的UNet_demo实现及训练自己的
- 多目标跟踪MOT16_Benchmark数据集链接
- LCSTS高质量中文短文本摘要数据集
- Qt软件开发 完整项目代码
- EMC中国人寿再保险公司数据集中存储
- 银行搜索数据集(bankresearch dataset)
- 常用数据挖掘数据集
- Google论文\“Wide & Deep Learning for Recom
- 深度学习数据集标注
- WEKA arff 实验数据集---数据挖掘用
- 基于决策树和朴素贝叶斯算法对Adul
- kinetics600.tar.gz
- 系统中ETL和数据集市的架构设计和实
- titanic_dataset.csv泰坦尼克数据集
- 北大中文《人民日报》199801-199806数据
- 贝叶斯应用案例测试集及源码
- 消费金融场景下的用户购买预测_数据
- 深度学习: MNIST的数据集
- kaggle信用卡欺诈数据
- 中国地面气候资料日值数据集201801-
- WS 445-2014电子病历基本数据集1-17全集
- 今日头条38万条新闻数据标题
- Oxford花卉数据加文本描述数据集
- zhwiki-20200720-pages-articles-multistream5.xm
- 卫生部WS 445-2014电子病历基本数据集
- PHM2008 挑战赛数据集
- 中国地面气候资料日值数据集(V3.0)
- 案例实战信用卡欺诈检测数据集
评论
共有 条评论