face-generator
face-generator copied to clipboard
Where can I find/generate the tfrecords for training?
Where can I find/generate the tfrecords for training?
The tfrecords aren't provided.
Sorry, I don't provide data file for training. You need to create it yourself...
If you tell me good dataset of face images, I'll add a script to create tfrecords
files based on that dataset.
I use my tfrecords, but is not work. Can you provide program about create tfrecords?
This is my error when I use my tfrecords : tensorflow.python.framework.errors_impl.InvalidArgumentError: Expected image (JPEG, PNG, or GIF), got unknown format starting with '\212\211\t?\204\203\003?\206\205\005?\330\326\326>'
This is my code to create tfrecords
import os
import matplotlib.image as mpimg
import tensorflow as tf
from PIL import Image
SAVE_PATH = r'D:\LearnPython\DCGAN\face-generator-master\data/dataset.tfrecords'
FACE_PATH = r'D:\LearnPython\DCGAN\face-generator-master\data\face2'
def resize(img_data, width, high, method=0):
return tf.image.resize_images(img_data, [width, high], method)
def _int64_feature(value):
return tf.train.Feature(int64_list=tf.train.Int64List(value=[value]))
def _bytes_feature(value):
return tf.train.Feature(bytes_list=tf.train.BytesList(value=[value]))
def load_data(width, high, method=0, save=False):
train_list = os.listdir(FACE_PATH)
writer = tf.python_io.TFRecordWriter(SAVE_PATH)
with tf.Session() as sess:
for line in train_list:
img_path = FACE_PATH+'/'+line
image = tf.gfile.FastGFile(img_path, 'rb').read()
image = tf.image.decode_jpeg(image)
image = tf.image.convert_image_dtype(image, dtype=tf.float32)
image = resize(image, width, high)
image = sess.run(image)
image_raw = image.tostring()
example = tf.train.Example(features=tf.train.Features(feature={
'image_raw': _bytes_feature(image_raw),
}))
writer.write(example.SerializeToString())
writer.close()
load_data(224, 224)
I am a novice, thank you.
@ayuLiao Maybe you should encode to jpeg binary after resize.
My program try to decode tfrecord's image_raw
data as jpeg binary.