使用tensorflow的retrain.py训练图片分类器


参考

https://hackernoon.com/creating-insanely-fast-image-classifiers-with-mobilenet-in-tensorflow-f030ce0a2991

https://github.com/tensorflow/tensorflow/blob/master/tensorflow/examples/image_retraining/retrain.py

https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#0

https://www.tensorflow.org/tutorials/image_retraining

 

准备图片

images/label1/1.jpg

      /2.jpg

images/label2/1.jpg

      /2.jpg

 

开始训练,默认Inception v3 model

python retrain.py \
  --bottleneck_dir=bottlenecks \
  --how_many_training_steps=500 \
  --model_dir=inception \
  --summaries_dir=training_summaries/basic \
  --output_graph=retrained_graph.pb \
  --output_labels=retrained_labels.txt \
  --image_dir=flower_photos

也可以使用其他模型

详细参数查看

python retrain.py -h

使用训练结果进行预测

参考https://codelabs.developers.google.com/codelabs/tensorflow-for-poets/#5

 

这样在训练好的inception-2015-12-05数据基础上

仅重新训练最后一层

用较短的时间达到分类效果

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM