Tensorflow——用google Inception retrain自己的图片

一  先完成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下面的三个参数改一下


估计结果:

二  训练自己的图片

直接把文件夹里的图片替换成自己的就可以了

猜你喜欢

转载自blog.csdn.net/eereere/article/details/80175849