0
我想用張量流加載圖像,但我需要按順序排列文件。當我加載圖像時,它會加載一個隨機圖像,但不是按照我通過初始數組提供的順序。但是,我的理解是,string_input_producer(file_names)是FIFO。爲什麼我的圖像是隨機的,我如何使它按順序加載圖像?在張量流隊列中加載圖像提供的是隨機圖像而不是FIFO
with open("name.json", 'r') as f:
data = json.load(f)
file_names = []
for i, row in enumerate(data):
load_location = row['location']
file_names.append(load_location)
filename_queue = tf.train.string_input_producer(file_names) # list of files to read
count_num_files = tf.size(file_names)
reader=tf.WholeFileReader()
key,value=reader.read(filename_queue)
img = tf.image.decode_png(value)
init = tf.global_variables_initializer()
with tf.Session() as sess:
sess.run(init)
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(coord=coord)
num_files = sess.run(count_num_files)
for i in range(num_files):
# this does not match
location = file_names[i]
# with this image
image_eval=img.eval()
coord.request_stop()
coord.join(threads)