Python 使用 TensorFlow 进行图像识别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/34694965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 15:23:10  来源:igfitidea点击:

Image recognition using TensorFlow

pythonimage-recognitiontensorflow

提问by Philip Adzanoukpe

I'm new to TensorFlow and I am looking for help on image recognition. Is there an example that showcases how to use TensorFlow to train your own digital images for image recognition like the image-net model used in the TensorFlow image recognition tutorial

我是 TensorFlow 的新手,我正在寻找图像识别方面的帮助。是否有一个示例展示了如何使用 TensorFlow 训练您自己的数字图像进行图像识别,例如TensorFlow 图像识别教程中使用的 image-net 模型

I looked at the CIFAR-10 model training but it doesn't seem to provide examples for training your own images.

我查看了 CIFAR-10 模型训练,但它似乎没有提供训练您自己的图像的示例。

采纳答案by Zhenyu Wu

I would recommend using Google's trained Inception model to do image recognition. Please refer to the example "How to Retrain Inception's Final Layer for New Categories" on tensorflow website. It is at https://www.tensorflow.org/versions/r0.9/how_tos/image_retraining/index.html.

我建议使用谷歌训练有素的 Inception 模型来进行图像识别。请参阅 tensorflow 网站上的示例“How to Retrain Inception's Final Layer for New Categories”。它位于https://www.tensorflow.org/versions/r0.9/how_tos/image_retraining/index.html

Using trained model is easy and can achieve reasonable accuracy. You just simply feed the model with your own data set. The last classication layer of Google's inception will be modified and we only train the last layer. For several thousand images with in several categories, it only take several hours to finish training. Please note: in order to use the example, you have to build tensorflow from source.

使用训练好的模型很容易,并且可以达到合理的精度。您只需使用您自己的数据集为模型提供数据。谷歌inception的最后一个分类层会被修改,我们只训练最后一层。对于几千张不同类别的图像,完成训练只需要几个小时。请注意:为了使用该示例,您必须从源代码构建 tensorflow。

I am using the transfer learning feature and achieving very good results. To illustrate the benefit of transfer learning, I am comparing "Transfer Learning on Trained GoogleNet" with "Build and train a 5-layer-Convnet from scratch". The classification task is done on 5000 images with 5 categories.

我正在使用迁移学习功能并取得了非常好的结果。为了说明迁移学习的好处,我将“在受过训练的 GoogleNet 上进行迁移学习”与“从头开始构建和训练 5 层 Convnet”进行比较。分类任务在 5000 张图像上完成,分为 5 个类别。

Build a 5-layer-convet and train it from scratch

构建一个 5 层卷积并从头开始训练

Use the transfer learning on the trained GoogleNet

在经过训练的 GoogleNet 上使用迁移学习

See this simple example: https://www.youtube.com/watch?v=QfNvhPx5Px8(Build a TensorFlow Image Classifier in 5 Min)

请参阅这个简单示例:https: //www.youtube.com/watch?v=QfNvhPx5Px8(在 5 分钟内构建 TensorFlow 图像分类器)

回答by shivakrishna9

This repo gives final layer image retraining for your own images.

此 repo 为您自己的图像提供最终层图像重新训练。

Add your images to the training_"dataset folder"

将您的图像添加到 training_"dataset 文件夹"

Add more and more images(atleast 30 images for each class required.)

添加越来越多的图像(每个类至少需要 30 张图像。)

First execute the bash script to download the Imagenet files.

首先执行bash脚本下载Imagenet文件。

Next, run the python script to retrain your images which outputs validation accuracy etc.,

接下来,运行 python 脚本来重新训练输出验证准确性等的图像,

https://github.com/shivakrishna9/tensorflow-retrain

https://github.com/shivakrishna9/tensorflow-retrain