def _read_raw_images(path, is_directory=True):
"""Reads directory of images in tensorflow
Args:
path:
is_directory:
Returns:
"""
images = []
png_files = []
jpeg_files = []
reader = tf.WholeFileReader()
png_files_path = glob.glob(os.path.join(path, '*.[pP][nN][gG]'))
jpeg_files_path = glob.glob(os.path.join(path, '*.[jJ][pP][eE][gG]'))
jpg_files_path = glob.glob(os.path.join(path, '*.[jJ][pP][gG]'))
if is_directory:
for filename in png_files_path:
png_files.append(filename)
for filename in jpeg_files_path:
jpeg_files.append(filename)
for filename in jpg_files_path:
jpeg_files.append(filename)
else:
raise ValueError('Currently only batch read from directory supported')
# Decode if there is a PNG file:
if len(png_files) > 0:
png_file_queue = tf.train.string_input_producer(png_files)
pkey, pvalue = reader.read(png_file_queue)
p_img = tf.image.decode_png(pvalue)
if len(jpeg_files) > 0:
jpeg_file_queue = tf.train.string_input_producer(jpeg_files)
jkey, jvalue = reader.read(jpeg_file_queue)
j_img = tf.image.decode_jpeg(jvalue)
return # TODO: return normal thing
评论列表
文章目录