码迷,mamicode.com
首页 > 其他好文 > 详细

使用TensorFlow识别照片中的物体

时间:2017-05-20 12:17:51      阅读:1356      评论:0      收藏:0      [点我收藏+]

标签:flow   html   识别   tar   api   rem   com   blank   esc   

1.环境ubuntu14.04.5

安装TensorFlow

官方文档:https://www.tensorflow.org/install/install_linux

sudo pip  install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl  

注意:后面的网址根据不同设置而不同:

 1 Python 2.7  
 2   
 3 CPU only:  
 4   
 5 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp27-none-linux_x86_64.whl  
 6 GPU support:  
 7   
 8 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl  
 9 Note that GPU support requires the NVIDIA hardware and software described in NVIDIA requirements to run TensorFlow with GPU support.  
10   
11 Python 3.4  
12   
13 CPU only:  
14   
15 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp34-cp34m-linux_x86_64.whl  
16 GPU support:  
17   
18 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp34-cp34m-linux_x86_64.whl  
19 Note that GPU support requires the NVIDIA hardware and software described in NVIDIA requirements to run TensorFlow with GPU support.  
20   
21 Python 3.5  
22   
23 CPU only:  
24   
25 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp35-cp35m-linux_x86_64.whl  
26 GPU support:  
27   
28 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp35-cp35m-linux_x86_64.whl  
29 Note that GPU support requires the NVIDIA hardware and software described in NVIDIA requirements to run TensorFlow with GPU support.  
30   
31 Python 3.6  
32   
33 CPU only:  
34   
35 https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-1.0.1-cp36-cp36m-linux_x86_64.whl  
36 GPU support:  
37   
38 https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp36-cp36m-linux_x86_64.whl  

我选择了相当于:python2.7 纯CPU

 

自动安装无误,若有安装失败,可能是网络问题,重新执行一遍试试。

也有可能是若干依赖没有装好:先把 各种依赖都安一遍 

下载神经网络模型:http://download.tensorflow.org/models/image/imagenet/inception-2015-12-05.tgz

1 mkdir model  
2 tar -xf archive_name.tar -C model/  

下载代码:https://codeload.github.com/tensorflow/models/zip/master

1 unzip models-master.zip  
2 cd models-master/tutorials/image/imagenet/  

其中的classify_image.py是我们实现物体识别的主代码

接下来做几个测试

1 classify_image.py --model_dir /home/usr/model --image_file /home/usr/model/cropped_panda.jpg  
2 classify_image.py --model_dir /home/usr/model --image_file /home/usr/model/testkb.jpg  
3 classify_image.py --model_dir /home/usr/model --image_file /home/usr/model/testmous.jpg  

技术分享技术分享技术分享

1 giant panda, panda, panda bear, coon bear, ailuropoda melanoleuca (score = 0.89107)
2 computer keyboard, keypad (score = 0.64016)
3 mouse, computer mouse(score = 0.89453)

技术分享

技术分享

技术分享

 

使用TensorFlow识别照片中的物体

标签:flow   html   识别   tar   api   rem   com   blank   esc   

原文地址:http://www.cnblogs.com/pandaroll/p/6881613.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!