项目作者: PINTO0309

项目描述 :
Edge TPU Accelerator / Multi-TPU / Multi-Model + Posenet/DeeplabV3/MobileNet-SSD + Python + Sync / Async + LaptopPC / RaspberryPi
高级语言: Python
项目地址: git://github.com/PINTO0309/TPU-Posenet.git
创建时间: 2019-08-18T01:51:55Z
项目社区:https://github.com/PINTO0309/TPU-Posenet

开源协议:MIT License

下载


TPU-Posenet

Edge TPU Accelerator/Multi-TPU/Multi-Model + Posenet/DeeplabV3/MobileNet-SSD + Python + Sync/Async + LaptopPC/RaspberryPi.
Inspired by google-coral/project-posenet.
This repository was tuned to speed up Google’s sample logic to support multi-TPU. And I replaced the complex Gstreamer implementation with the OpenCV implementation.

0. Table of contents

1. Environment
2. Inference behavior
 2-1. Async, TPU x3, USB Camera, Single Person
 2-2. Sync, TPU x1, USB Camera, Single Person
 2-3. Sync, TPU x1, MP4 (30 FPS), Multi Person
 2-4. Async, TPU x3, USB Camera (30 FPS), Multi-Model, Posenet + DeeplabV3 + MobileNet-SSDv2
3. Introduction procedure
 3-1. Common procedures for devices
 3-2-1. Only Linux
 3-2-2. Only RaspberryPi (Stretch or Buster)
4. Usage
5. Reference articles

1. Environment

  • Ubuntu or RaspberryPi
    • (Note: Because RaspberryPi3 is a low-speed USB 2.0, multi-TPU operation becomes extremely unstable.)
  • OpenCV4.1.1-openvino
  • Coral Edge TPU Accelerator (Multi-TPU)
    • Automatically detect the number of multiple TPU accelerators connected to a USB hub to improve performance.
  • USB Camera (Playstationeye)
  • Picamera v2
  • Self-powered USB 3.0 Hub
  • Python 3.5.2+

07

2. Inference behavior

2-1. Async, TPU x3, USB Camera, Single Person

Youtube:https://youtu.be/LBk71RKca1c
08

2-2. Sync, TPU x1, USB Camera, Single Person

Youtube:https://youtu.be/GuuXzpLXFJo
09

2-3. Sync, TPU x1, MP4 (30 FPS), Multi Person

Youtube:https://youtu.be/ibPuI12bj2w
10

2-4. Async, TPU x3, USB Camera (30 FPS), Multi-Model, Posenet + DeeplabV3 + MobileNet-SSDv2

Youtube:https://youtu.be/d946VOE65tU
11

3. Introduction procedure

3-1. Common procedures for devices

  1. $ sudo apt-get update;sudo apt-get upgrade -y
  2. $ sudo apt-get install -y python3-pip
  3. $ sudo pip3 install pip --upgrade
  4. $ sudo pip3 install numpy
  5. $ wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
  6. $ tar xzf edgetpu_api.tar.gz
  7. $ sudo edgetpu_api/install.sh
  8. $ git clone https://github.com/PINTO0309/TPU-Posenet.git
  9. $ cd TPU-Posenet.git
  10. $ cd models;./download.sh;cd ..
  11. $ cd media;./download.sh;cd ..

3-2-1. Only Linux

  1. $ wget https://github.com/PINTO0309/OpenVINO-bin/raw/master/Linux/download_2019R2.sh
  2. $ chmod +x download_2019R2.sh
  3. $ ./download_2019R2.sh
  4. $ l_openvino_toolkit_p_2019.2.242/install_openvino_dependencies.sh
  5. $ ./install_GUI.sh
  6. OR
  7. $ ./install.sh

3-2-2. Only RaspberryPi (Stretch or Buster)

  1. ### Only Raspbian Buster ############################################################
  2. $ cd /usr/local/lib/python3.7/dist-packages/edgetpu/swig/
  3. $ sudo cp \
  4. _edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so \
  5. _edgetpu_cpp_wrapper.cpython-37m-arm-linux-gnueabihf.so
  6. ### Only Raspbian Buster ############################################################
  7. $ cd ~/TPU-Posenet
  8. $ sudo pip3 install imutils
  9. $ sudo raspi-config

01
02
03
04
05
06

  1. $ wget https://github.com/PINTO0309/OpenVINO-bin/raw/master/RaspberryPi/download_2019R2.sh
  2. $ sudo chmod +x download_2019R2.sh
  3. $ ./download_2019R2.sh
  4. $ echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
  5. $ source ~/.bashrc

4. Usage

  1. usage: pose_camera_multi_tpu.py [-h] [--model MODEL] [--usbcamno USBCAMNO]
  2. [--videofile VIDEOFILE] [--vidfps VIDFPS]
  3. optional arguments:
  4. -h, --help show this help message and exit
  5. --model MODEL Path of the detection model.
  6. --usbcamno USBCAMNO USB Camera number.
  7. --videofile VIDEOFILE
  8. Path to input video file. (Default="")
  9. --vidfps VIDFPS FPS of Video. (Default=30)
  1. usage: pose_camera_single_tpu.py [-h] [--model MODEL] [--usbcamno USBCAMNO]
  2. [--videofile VIDEOFILE] [--vidfps VIDFPS]
  3. optional arguments:
  4. -h, --help show this help message and exit
  5. --model MODEL Path of the detection model.
  6. --usbcamno USBCAMNO USB Camera number.
  7. --videofile VIDEOFILE
  8. Path to input video file. (Default="")
  9. --vidfps VIDFPS FPS of Video. (Default=30)
  1. usage: pose_picam_multi_tpu.py [-h] [--model MODEL] [--videofile VIDEOFILE] [--vidfps VIDFPS]
  2. optional arguments:
  3. -h, --help show this help message and exit
  4. --model MODEL Path of the detection model.
  5. --videofile VIDEOFILE
  6. Path to input video file. (Default="")
  7. --vidfps VIDFPS FPS of Video. (Default=30)
  1. usage: pose_picam_single_tpu.py [-h] [--model MODEL] [--videofile VIDEOFILE] [--vidfps VIDFPS]
  2. optional arguments:
  3. -h, --help show this help message and exit
  4. --model MODEL Path of the detection model.
  5. --videofile VIDEOFILE
  6. Path to input video file. (Default="")
  7. --vidfps VIDFPS FPS of Video. (Default=30)
  1. usage: ssd-deeplab-posenet.py [-h] [--pose_model POSE_MODEL]
  2. [--deep_model DEEP_MODEL]
  3. [--ssd_model SSD_MODEL] [--usbcamno USBCAMNO]
  4. [--videofile VIDEOFILE] [--vidfps VIDFPS]
  5. [--camera_width CAMERA_WIDTH]
  6. [--camera_height CAMERA_HEIGHT]
  7. optional arguments:
  8. -h, --help show this help message and exit
  9. --pose_model POSE_MODEL
  10. Path of the posenet model.
  11. --deep_model DEEP_MODEL
  12. Path of the deeplabv3 model.
  13. --ssd_model SSD_MODEL
  14. Path of the mobilenet-ssd model.
  15. --usbcamno USBCAMNO USB Camera number.
  16. --videofile VIDEOFILE
  17. Path to input video file. (Default="")
  18. --vidfps VIDFPS FPS of Video. (Default=30)
  19. --camera_width CAMERA_WIDTH
  20. USB Camera resolution (width). (Default=640)
  21. --camera_height CAMERA_HEIGHT
  22. USB Camera resolution (height). (Default=480)

5. Reference articles

  1. Edge TPU USB Accelerator analysis - I/O data transfer - Qiita - iwatake2222

  2. [150 FPS ++] Connect three Coral Edge TPU accelerators and infer in parallel processing to get ultra-fast object detection inference performance ーTo the extreme of useless high performanceー - Qiita - PINTO

  3. [150 FPS ++] Connect three Coral Edge TPU accelerators and infer in parallel processing to get ultra-fast Posenet inference performance ーTo the extreme of useless high performanceー - Qiita - PINTO

  4. Raspberry Pi Camera Module