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.
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
- 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+
Youtube:https://youtu.be/LBk71RKca1c
Youtube:https://youtu.be/GuuXzpLXFJo
Youtube:https://youtu.be/ibPuI12bj2w
Youtube:https://youtu.be/d946VOE65tU
$ sudo apt-get update;sudo apt-get upgrade -y
$ sudo apt-get install -y python3-pip
$ sudo pip3 install pip --upgrade
$ sudo pip3 install numpy
$ wget https://dl.google.com/coral/edgetpu_api/edgetpu_api_latest.tar.gz -O edgetpu_api.tar.gz --trust-server-names
$ tar xzf edgetpu_api.tar.gz
$ sudo edgetpu_api/install.sh
$ git clone https://github.com/PINTO0309/TPU-Posenet.git
$ cd TPU-Posenet.git
$ cd models;./download.sh;cd ..
$ cd media;./download.sh;cd ..
$ wget https://github.com/PINTO0309/OpenVINO-bin/raw/master/Linux/download_2019R2.sh
$ chmod +x download_2019R2.sh
$ ./download_2019R2.sh
$ l_openvino_toolkit_p_2019.2.242/install_openvino_dependencies.sh
$ ./install_GUI.sh
OR
$ ./install.sh
### Only Raspbian Buster ############################################################
$ cd /usr/local/lib/python3.7/dist-packages/edgetpu/swig/
$ sudo cp \
_edgetpu_cpp_wrapper.cpython-35m-arm-linux-gnueabihf.so \
_edgetpu_cpp_wrapper.cpython-37m-arm-linux-gnueabihf.so
### Only Raspbian Buster ############################################################
$ cd ~/TPU-Posenet
$ sudo pip3 install imutils
$ sudo raspi-config
$ wget https://github.com/PINTO0309/OpenVINO-bin/raw/master/RaspberryPi/download_2019R2.sh
$ sudo chmod +x download_2019R2.sh
$ ./download_2019R2.sh
$ echo "source /opt/intel/openvino/bin/setupvars.sh" >> ~/.bashrc
$ source ~/.bashrc
Run Sample
> python pose_camera_single_tpu.py --model .\models\mobilenet\posenet_mobilenet_v1_075_481_641_quant_decoder_edgetpu.tflite
usage: pose_camera_multi_tpu.py [-h] [--model MODEL] [--usbcamno USBCAMNO]
[--videofile VIDEOFILE] [--vidfps VIDFPS]
optional arguments:
-h, --help show this help message and exit
--model MODEL Path of the detection model.
--usbcamno USBCAMNO USB Camera number.
--videofile VIDEOFILE
Path to input video file. (Default="")
--vidfps VIDFPS FPS of Video. (Default=30)
usage: pose_camera_single_tpu.py [-h] [--model MODEL] [--usbcamno USBCAMNO]
[--videofile VIDEOFILE] [--vidfps VIDFPS]
optional arguments:
-h, --help show this help message and exit
--model MODEL Path of the detection model.
--usbcamno USBCAMNO USB Camera number.
--videofile VIDEOFILE
Path to input video file. (Default="")
--vidfps VIDFPS FPS of Video. (Default=30)
usage: pose_picam_multi_tpu.py [-h] [--model MODEL] [--videofile VIDEOFILE] [--vidfps VIDFPS]
optional arguments:
-h, --help show this help message and exit
--model MODEL Path of the detection model.
--videofile VIDEOFILE
Path to input video file. (Default="")
--vidfps VIDFPS FPS of Video. (Default=30)
usage: pose_picam_single_tpu.py [-h] [--model MODEL] [--videofile VIDEOFILE] [--vidfps VIDFPS]
optional arguments:
-h, --help show this help message and exit
--model MODEL Path of the detection model.
--videofile VIDEOFILE
Path to input video file. (Default="")
--vidfps VIDFPS FPS of Video. (Default=30)
usage: ssd-deeplab-posenet.py [-h] [--pose_model POSE_MODEL]
[--deep_model DEEP_MODEL]
[--ssd_model SSD_MODEL] [--usbcamno USBCAMNO]
[--videofile VIDEOFILE] [--vidfps VIDFPS]
[--camera_width CAMERA_WIDTH]
[--camera_height CAMERA_HEIGHT]
optional arguments:
-h, --help show this help message and exit
--pose_model POSE_MODEL
Path of the posenet model.
--deep_model DEEP_MODEL
Path of the deeplabv3 model.
--ssd_model SSD_MODEL
Path of the mobilenet-ssd model.
--usbcamno USBCAMNO USB Camera number.
--videofile VIDEOFILE
Path to input video file. (Default="")
--vidfps VIDFPS FPS of Video. (Default=30)
--camera_width CAMERA_WIDTH
USB Camera resolution (width). (Default=640)
--camera_height CAMERA_HEIGHT
USB Camera resolution (height). (Default=480)