Exemple #1
0
input_data_2 = tf.placeholder(tf.float32, shape=(None, 227, 227, 3))
input_data_3 = tf.placeholder(tf.float32, shape=(None, 227, 227, 3))

net = AlexNet({'data': input_data})

print 'Initial Variable List:'
print[tt.name for tt in tf.trainable_variables()]

image_paths = glob.glob('data/*.JPEG')
image_reader = ImageReader(image_paths=image_paths, batch_size=100)

with tf.Session() as sesh:
    # load model weights
    model_data = 'alexnet_weights.npy'

    net.load(model_data, sesh)

    # start image reading
    coordinator = tf.train.Coordinator()
    threads = image_reader.start_reader(session=sesh, coordinator=coordinator)

    # get a batch
    indices, input_images = image_reader.get_batch(sesh)

    # get labels
    probs = sesh.run(net.get_output(), feed_dict={input_data: input_images})
    display_results([image_paths[i] for i in indices], probs)

    coordinator.request_stop()
    coordinator.join(threads, stop_grace_period_secs=2)