I trained Tensorflow Cifar10 model and I would like to feed it with own single image (32*32, jpg/png).
I want to see label and probability of each label as an output, bu
The video https://youtu.be/d9mSWqfo0Xw shows an example for classifying a single image.
After the network has already trained by python cifar10_train.py we evaluate the individual image deer6.png of CIFAR-10 database and an own photo of a matchbox. The most important modifications of the original source code of the TF tutorial are the following:
First it is necessary to convert these images to a binary form that the cifar10_input.py can read. It can be done easily by using the code snippet that can be found at How to create dataset similar to cifar-10
Then in order to read the converted images (called input.bin) we need modify the function input() in cifar10_input.py:
else:
#filenames = [os.path.join(data_dir, 'test_batch.bin')]
filenames = [os.path.join(data_dir, 'input.bin')]
(data_dir is equal to './')
Finally to get the label we have modify the function eval_once() in source cifar10_eval.py:
#while step < num_iter and not coord.should_stop():
# predictions = sess.run([top_k_op])
print(sess.run(logits[0]))
classification = sess.run(tf.argmax(logits[0], 0))
cifar10classes = ["airplane", "automobile", "bird", "cat", "deer", "dog", "frog", "horse", "ship", "truck"]
print(cifar10classes[classification])
#true_count += np.sum(predictions)
step += 1
# Compute precision @ 1.
precision = true_count / total_sample_count
# print('%s: precision @ 1 = %.3f' % (datetime.now(), precision))
And of course there are some small modifications that you will need to make.