美文网首页我爱编程
【Tensorflow】基于Inception-v3模型的图像分

【Tensorflow】基于Inception-v3模型的图像分

作者: 下里巴人也 | 来源:发表于2018-05-17 11:22 被阅读377次

1. inception-v3 简介

The Inception v3 model is a deep convolutional neural network, which has been pre-trained for the ImageNet Large Visual Recognition Challenge using data from 2012, and it can differentiate between 1,000 different classes, like “cat”, “dishwasher” or “plane”.

The TensorFlow team already prepared a tutorial on how to execute the image classification on your machine. Nevertheless, I’ll show you as well.

2. 官方分类模型使用

下载Tensorflow/models,用tensorflow提供的classify_image进行图像分类:

git clone https://github.com/tensorflow/models.git
cd models/tutorials/image/imagenet
python classify_image.py

执行 python classify_image.py结果如下:

classify_image.py会首先下载分类器模型:
DATA_URL = 'http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz'
下载后会放到本地/tmp/imagenet/路径下:

3. 训练自己的模型

  • 下载代码:
git clone https://github.com/koflerm/tensorflow-image-classifier.git

代码目录:

  • 到当前目录创建两个文件夹:tf_files 和 training_dataset:
  • 把图片素材放到training_dataset目录下,图片素材格式如下:
Here's an example, which assumes you have a folder containing class-named 
subfolders, each full of images for each label. The example folder flower_photos
should have a structure like this: 
~/flower_photos/daisy/photo1.jpg
~/flower_photos/daisy/photo2.jpg
~/flower_photos/rose/anotherphoto77.jpg
~/flower_photos/sunflower/somepicture.jpg

例如,我的素材格式如下:

  • 训练
    直接调用./train.sh开始训练

  • 执行识别命令

python classify.py [image path]

结果如下:

相关文章

网友评论

    本文标题:【Tensorflow】基于Inception-v3模型的图像分

    本文链接:https://www.haomeiwen.com/subject/bcfbdftx.html