Tensorflow retrain.py Directory image not found error
I am testing Tensorflow for Poets from here , which reinstalls the latest late Inception on Ubuntu 14.04 processor
after the guide i ran this code
python tensorflow/examples/image_retraining/retrain.py \
–bottleneck_dir=tf_files/bottlenecks \
–how_many_training_steps 500 \
–model_dir=tf_files/inception \
–output_graph=tf_files/retrained_graph.pb \
–output_labels=tf_files/retrained_labels.txt \
–image_dir=tf_files/flower_photos
and I got the following error:
Image directory '' not found.
Traceback (most recent call last):
File "tensorflow/examples/image_retraining/retrain.py", line 774, in <module>
tf.app.run()
File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv))
File "tensorflow/examples/image_retraining/retrain.py", line 671, in main
class_count = len(image_lists.keys())
AttributeError: 'NoneType' object has no attribute 'keys
The knowledge of this issue refers to where my images are stored, I put them in my home folder which correctly refers to the last command image_dir=tf_files/flower_photos
So now my question is, why am I getting this error even though the image directory is correct?
source to share
If you look at line 774 where the error occurs, it is the summary directory, not the image_dir.
You will need to set the summary directory here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py#L928
source to share
retrain.py now exists in the following location:
github.com/tensorflow/hub/raw/master/examples/image_retraining/retrain.py
instead
tensorflow/examples/image_retraining
You can use this:
curl -LO https://github.com/tensorflow/tensorflow/raw/master/tensorflow/examples/label_image/label_image.py python label_image.py \
--graph=/tmp/output_graph.pb --labels=/tmp/output_labels.txt \
--input_layer=Placeholder \
--output_layer=final_result \
--image=$HOME/flower_photos/daisy/21652746_cc379e0eea_m.jpg
Link: https://www.tensorflow.org/hub/tutorials/image_retraining
source to share
There is no double hyphen in your code block. So try this:
python tensorflow/examples/image_retraining/retrain.py \
–-bottleneck_dir=tf_files/bottlenecks \
–-how_many_training_steps 500 \
–-model_dir=tf_files/inception \
–-output_graph=tf_files/retrained_graph.pb \
–-output_labels=tf_files/retrained_labels.txt \
–-image_dir=tf_files/flower_photos
source to share
Step 1
Follow this link:
Step 2
Go to the second chapter
Step 3
Worked by adding two lines as below before the script section: LOL
It's LOL that just added the next two lines and it worked up to the script section and it worked.
Two lines:
if not os.path.isdir("../Pokemons-subset"):
print('Error')
Script section:
%run scripts/retrainn.py \
--bottleneck_dir=tf_files/bottlenecks \
--how_many_training_steps=4000 \
--model_dir=tf_files/models/ \
--summaries_dir=tf_files/training_summaries/mobilenet_0.50_160 \
--output_graph=tf_files/retrained_graph.pb \
--output_labels=tf_files/retrained_labels.txt \
--learning_rate=0.01 \
--architecture=mobilenet_0.50_160 \
--image_dir=../Pokemons-subset \
--flip_left_right \
--random_crop=10 \
--random_scale=10 \
--random_brightness=10
source to share