Tensorflow实现物体识别


系统环境 Ubuntu16.04 64位
Python 3.5 (Ubuntu默认python3版本)
软件 PyCharm


  1. 安装PyCharm

    1. 下载压缩包,解压之
    2. 设置快捷方式
  2. 新建PyCharm项目

    1. 下载tensorflow/models源文件

      git clone https://github.com/tensorflow/models.git
    2. 安装API
      以下内容参考自GitHub。

      1. 安装依赖(鉴于本人使用python虚拟环境)

        pip isntall tensorflow
        pip install Cython
        pip install pillow
        pip install lxml
        pip install jupyter
        pip install matplotlib
      2. 安装COCO API

        git clone https://github.com/cocodataset/cocoapi.git
        cd cocoapi/PythonAPI
        make
        cp -r pycocotools /models/research/

      此步失败,问题尚未解决

      1. 编译protobuf

        sudo apt install protobuf-compiler
        protoc object_detection/protos/*.proto --python_out=. #切换到models/research目录下
      2. 导入环境变量

        
        # 当前目录位于models/research
        
        export PYTHONPATH=$PYTHONPATH:`pwd`:`pwd`/slim #建议将其导入~/.bashrc

      提示OK,表明成功。
      如果失败,可以考虑新建.pth文件于site-packages目录下,其内容为

      xxx/models/research/object_detection/
      XXX/models/research/object_detection/slim

      参考自window系统下出现问题时的解决方案。

    3. 测试object detection API
      在models目录下,输入命令
      juptyer-notebook

    在浏览器中依次打开research/object_detection/object_detection_tutorials.ipynb
    连按shift+Enter,直至最后一行,等待数秒,会显示出测试图片的检测结果。

你可能感兴趣的:(AI)