一 先完成google的例子
1)下載用於分類的 code
git clone https://github.com/googlecodelabs/tensorflow-for-poets-2
cd tensorflow-for-poets-2
2)下載五種花的圖片
curl http://download.tensorflow.org/example_images/flower_photos.tgz \
| tar xz -C tf_files
然後複製到tf_files
3)打開tensorboard
我還沒在這個環境裏安裝,先pip install tensorboard
tensorboard --logdir tf_files/training_summaries &
4)開始retrain Inception v3
強大的google已經把所有的東西都集成好了
python -m scripts.retrain \ --bottleneck_dir=tf_files/bottlenecks \ --how_many_training_steps=500 \ --model_dir=tf_files/models/ \ --summaries_dir=tf_files/training_summaries/"${ARCHITECTURE}" \ --output_graph=tf_files/retrained_graph.pb \ --output_labels=tf_files/retrained_labels.txt \ --architecture="${ARCHITECTURE}" \ --image_dir=tf_files/flower_photos
5)測試
python -m scripts.label_image --graph=tf_files/retrained_graph.pb --image=tf_files/flower_photos/daisy/21652746_cc379e0eea_m.jpg
在這裏出現了一個小錯誤:
The name 'import/input' refers to an Operation not in the graph.
把~/scripts/label_image.py77下面的三個參數改一下
估計結果:
二 訓練自己的圖片
直接把文件夾裏的圖片替換成自己的就可以了