• 使用TensorFlow识别照片中的物体


    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)

  • 相关阅读:
    机房收费系统——报表(2)
    机房收费系统——报表(1)
    机房收费系统之结账
    机房管理系统——vb与excel链接2
    机房管理系统——VB与Excel的链接
    Unity
    Android Dev Tips
    Android JSON And Object Cast
    Android Screen Orientation
    iOS8 with Swift
  • 原文地址:https://www.cnblogs.com/pandaroll/p/6881613.html
Copyright © 2020-2023  润新知