TensorFlow入门-Inception(v3)图像识别

Inception-v3是最新的一个模型,在ImageNet-2012上训练进行分类。

与其他网络对比

AlexNet achieved by setting a top-5 error rate of 15.3% on the 2012 validation data set; BN-Inception-v2 achieved 6.66%; Inception-v3 reaches 3.46%.

How well do humans do on ImageNet Challenge? There’s a blog post by Andrej Karpathy who attempted to measure his own performance. He reached 5.1% top-5 error rate.

我猜人类的识别率应该很大程度受限于一个人的知识水平。比如对于猫而言,我们只知道很少几个品种,而计算机却可以存储很多品种的猫的信息。

调用Python API

在cmd中输入

cd tensorflow/models/image/imagenet
python classify_image.py

自动在官网下载训练好的Inception-v3模型,和相关文件(一张测试图像cropped_panda.jpg)


这里写图片描述

Inception-v3自动分类此图像,结果为

giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca (score = 0.88493)
indri, indris, Indri indri, Indri brevicaudatus (score = 0.00878)
lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens (score = 0.00317)
custard apple (score = 0.00149)
earthstar (score = 0.00127)

测试自定义图像,使用–image_file参数

python classify_iamge.py –image_file=img_dir

比如
1.


TensorFlow入门-Inception(v3)图像识别_第1张图片

convertible (score = 0.52526)敞篷车
sports car, sport car (score = 0.34500)跑车
grille, radiator grille (score = 0.01084)
car wheel (score = 0.00232)
amphibian, amphibious vehicle (score = 0.00137)
前两者置信度都挺高,30%+,那更合理的结果是不是敞篷跑车?
2.


TensorFlow入门-Inception(v3)图像识别_第2张图片

Egyptian cat (score = 0.14357)埃及猫
tabby, tabby cat (score = 0.07122)
tiger cat (score = 0.06887)
Persian cat (score = 0.02849)
window screen (score = 0.02827)
An exception has occurred, use %tb to see the full traceback.
头一次听说埃及猫:)
3.


TensorFlow入门-Inception(v3)图像识别_第3张图片

comic book (score = 0.11628)动漫书
coffee mug (score = 0.03781)
cup (score = 0.02944)
shower curtain (score = 0.02505)
desktop computer (score = 0.02169)

如果问一个人,这是什么,大多数回答是一只猫吧。结果是comic book,看来图像风格(style)对CNN结果有很大影响。
4.


TensorFlow入门-Inception(v3)图像识别_第4张图片

German shepherd, German shepherd dog, German police dog, alsatian (score = 0.95344)德国牧羊犬
malinois (score = 0.00227)
bulletproof vest (score = 0.00115)
bloodhound, sleuthhound (score = 0.00110)
muzzle (score = 0.00071)
经典的样本!
5.


TensorFlow入门-Inception(v3)图像识别_第5张图片

chow, chow chow (score = 0.82244) 中华田园犬
tabby, tabby cat (score = 0.01480)虎纹猫
Eskimo dog, husky (score = 0.00772)
dingo, warrigal, warragal, Canis dingo (score = 0.00715)
American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier (score = 0.00627)
多个目标的情况,top-1更关注较大的dog?但是top-2的预测表明cat的存在。
6.


TensorFlow入门-Inception(v3)图像识别_第6张图片

gown (score = 0.11101)女礼服,长袍,睡衣
picket fence, paling (score = 0.10401)围栏
hoopskirt, crinoline (score = 0.10057)裙子
maypole (score = 0.07265)
overskirt (score = 0.06151)

为什么答案不是一个漂亮的小女孩,而是长裙子,关注点果然不一样!

你可能感兴趣的:(深度学习,TensorFlow)