I will omit the explanation of Inception. Please refer to the following site TensorFlow: Tutorials: Image Recognition TensorFlow Tutorial-Image Recognition (Translation)
Last time Make "classify_image" available for the built environment
$ git clone https://github.com/tensorflow/tensorflow.git cd tensorflow/models/image/imagenet
If no argument is specified, the classification result of the panda image will be displayed.
python classify_image.py giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.88493) indri, indris, Indri indri, Indri brevicaudatus (score = 0.00878) lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00317) custard apple (score = 0.00149) earthstar (score = 0.00127)
Something like this
/home/vagrant/my_tensorflow/images/image01.jpg /home/vagrant/my_tensorflow/images/image02.jpg /home/vagrant/my_tensorflow/images/image03.jpg /home/vagrant/my_tensorflow/images/image04.jpg /home/vagrant/my_tensorflow/images/image05.jpg
Move the classified image files to a directory.
#!/bin/bash -x
FILES=`cat /home/vagrant/my_tensorflow/train.csv | tr -d ' '`
for FILE in $FILES
do
DIR="/tmp/image/"`python /home/vagrant/tensorflow/tensorflow/models/image/imagenet/classify_image.py --image_file ${FILE} | awk 'NR==1{print $1}' | tr -d "," | tr -d ' ' `"/"
echo "-------------------"
echo "FILE:$FILE"
echo "DIR:$DIR"
mkdir $DIR
mv $FILE $DIR
done
ls /tmp/image/comic/ image02.jpg image04.jpg
Recommended Posts