【发布时间】:2016-07-04 16:08:55
【问题描述】:
我一直在尝试将 1750 * 1750 图像输入到 Tensorflow,但在使用 tf.image.decode_jpeg() 函数将图像转换为张量后,我不知道如何标记和输入数据。
目前,我的代码是:
import tensorflow as tf
import numpy as np
import imageflow
import os, glob
sess = tf.InteractiveSession()
def read_jpeg(filename_queue):
reader = tf.WholeFileReader()
key, value = reader.read(filename_queue)
my_img = tf.image.decode_jpeg(value)
my_img.set_shape([1750, 1750, 1])
print(value)
return my_img
#####################################################
def read_image_data():
jpeg_files = []
images_tensor = []
i = 1
WORKING_PATH = "/Users/Zanhuang/Desktop/NNP/DATA"
jpeg_files_path = glob.glob(os.path.join(WORKING_PATH, '*.jpeg'))
for filename in jpeg_files_path:
print(i)
i += 1
jpeg_files.append(filename)
filename_queue = tf.train.string_input_producer(jpeg_files)
mlist = [read_jpeg(filename_queue) for _ in range(len(jpeg_files))]
init = tf.initialize_all_variables()
sess = tf.Session()
sess.run(init)
images_tensor = tf.convert_to_tensor(images_tensor)
sess.close()
现在,正如我之前所说,我需要输入和标记数据。我看过 CIFAR-10 教程文件,但他们将标签存储在一个文件中,我打算不这样做。
我是 Tensorflow 的新手,所以请尽可能详细地回复。
谢谢!
【问题讨论】:
-
用同样格式的MINST_data,用input_data.py读取怎么样?
标签: python image-processing machine-learning jpeg tensorflow