I tried to classify by tensorflow, so I will leave a note. When classifying images in the environment of a fairly old PC (Ubuntu is installed on a PC about 10 years ago) It seems that it will not work according to the CPU specifications unless the tensor flow version is set to 1.5.
Create a learning model by classifying with a file called retrain.py. This time, I learned the image of Naruko and the image of a cat. (The images of cats and Naruko are put in folders)
Judge the test image by referring to the training model in a file called label_image.py. This time, I prepared Naruko for the test image and judged it.
In addition, the location such as hierarchy is passed as a parameter to each file.
pip install tensorflow==1.5
pip install tensorflow_hub==0.2.0
python retrain.py \
--bottleneck_dir=bottlenecks \
--how_many_training_steps=1000 \
--model_dir=inception \
--summaries_dir=training_summaries/basic \
--output_graph=retrained_graph.pb \
--output_labels=retrained_labels.txt \
--image_dir=img
python label_image.py \
--graph=retrained_graph.pb \
--labels=retrained_labels.txt \
--output_layer=final_result \
--image=test_images/x.jpg \
--input_layer=Mul
Download the source from below https://github.com/tensorflow/tensorflow/tree/r1.5/tensorflow
wget https://raw.githubusercontent.com/tensorflow/tensorflow/r1.5/tensorflow/examples/label_image/label_image.py
wget https://raw.githubusercontent.com/tensorflow/tensorflow/r1.5/tensorflow/examples/image_retraining/retrain.py
Recommended Posts