วันอังคารที่ 2 สิงหาคม พ.ศ. 2565

Raspberry pi YOLO Object detection with Intel Neural compute stick and OpenVINO

Raspberry pi YOLO Object detection with Intel Neural compute stick and OpenVINO 

Hardware · Raspberry Pi Board (4B ) · Intel Neural Compute Stick 2 · SD Card 32GB · 5V DC. 2A Power Supply Software · OS Raspbian 10 ( Buster ) · Python 3.7.3 · OpenVINO Toolkit 2020.3 · OpenCV 4.0.0

What is a YOLO object detector?

When it comes to deep learning-based object detection, there are three primary object detectors you’ll encounter:

  • R-CNN and their variants, including the original R-CNN, Fast R- CNN, and Faster R-CNN
  • Single Shot Detector (SSDs)
  • YOLO
First introduced in 2015 by Redmon et al., their paper, You Only Look Once: Unified, Real-Time Object Detection, details an object detector capable of super real-time object detection, obtaining 45 FPS on a GPU.

You Only Look Once: Unified, Real-Time Object Detection

https://arxiv.org/pdf/1506.02640v3.pdf


YOLOv3 improved on the YOLOv2 paper and both Joseph Redmon and Ali Farhadi, the original authors, contributed.
Together they published YOLOv3: An Incremental Improvement

The original YOLO papers were are hosted here

Author: Joseph Redmon and Ali Farhadi
Released: 8 Apr 2018

We’ll be using YOLOv3 in this blog post, in particular, YOLO trained on the COCO dataset.

The COCO dataset consists of 80 labels.

YOLOv3-416


Video Inference Performance    3 FPS.




YOLOv3-tiny-416


Video Inference Performance    7 FPS.




Compare Performance



Reference

Raspberry pi OpenVINO with Intel Movidius ( Neural Compute Stick )


Install OpenVINO™ toolkit for Raspbian* OS https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html


Adun Nantakaew อดุลย์ นันทะแก้ว 081-6452400
LINE : adunnan

วันศุกร์ที่ 15 กรกฎาคม พ.ศ. 2565

Raspberry pi 4B Object Detection with Intel Neural Compute Stick and OpenVINO

Raspberry pi Object Detection with Intel Neural Compute Stick and OpenVINO

This project showcases Object Detection on edge device.

We use Raspberry pi 4B board with Intel NCS ( Neural Compute Stick ) and OpenVINO Library and Source code from Intel AI.

 

Hardware

·     Raspberry Pi Board (4B )
·     Intel Neural Compute Stick 2
·     SD Card 32GB
·     5V DC. 2A Power Supply

Software

·     OS Raspbien 10 ( Buster )
·     Python 3.7.3
·     OpenVINO Toolkit 2019.R3
·     OpenCV 4.0.0

Machine Learning Object Detection Model : Mobilenet SSD V2

Run Python Code ( Async Mode )

Async API usage can improve overall frame-rate of the application, because rather than wait for inference to complete, the app can continue doing things on the host, while accelerator is busy.

This and other performance implications and tips for the Async API are covered in the Optimization Guide.

Other demo objectives are:

  • Video as input support via OpenCV*

  • Visualization of the resulting bounding boxes and text labels (from the .labels file) or class number (if no file is provided)



Video Test   : 960x540 pixels

Total frame  : 301 frames

Total Inference time   : 12.44 sec

Average performance : 24.20 fps

Run Python Code ( Sync Mode )





Video Test   : 960x540 pixels

Total frame  : 301 frames

Total Inference time   : 24.96 sec

Average performance : 12.06 fps


OpenVINO Toolkit

Now We try to use OpenVINO 2020.3 compare with OpenVINO 2019 R3.

OpenVINO 2020.3 frame rate is a little bit lower than OpenVINO 2019 R3.



Comparison

Async vs Sync Mode














This is my experiment may something was wrong.









YouTube Video

Raspberry pi Object Detection with Intel Neural Compute Stick and OpenVINO ( 2020.3 )

Compare Raspberry pi Object Detection Intel NCS ( Async vs. Sync mode )

Raspberry pi Object Detection with Intel Neural Compute Stick ( Sync mode )

Raspberry pi Object Detection with Intel Neural Compute Stick ( Async mode )

Compare Raspberry pi Object Detection ( TensorFlow vs. TensorFlow-lite ) 

Raspberry pi Object Detection with TensorFlow-lite ( INT8 )

Raspberry pi Object Detection with TensorFlow ( FP32 )

Reference

Raspberry pi OpenVINO with Intel Movidius ( Neural Compute Stick )

 

Install OpenVINO™ toolkit for Raspbian* OS

https://docs.openvino.ai/latest/openvino_docs_install_guides_installing_openvino_raspbian.html

Object Detection Python* Demo

https://docs.openvino.ai/latest/omz_demos_object_detection_demo_python.html

Model ( SSD MobileNet )


https://docs.openvino.ai/latest/omz_models_model_ssd_mobilenet_v1_coco.html


https://docs.openvino.ai/latest/omz_models_model_ssdlite_mobilenet_v2.html



OpenVINO Optimization


https://docs.openvino.ai/latest/openvino_docs_optimization_guide_dldt_optimization_guide.html



Adun Nantakaew อดุลย์ นันทะแก้ว 081-6452400
LINE : adunnan

    

วันพุธที่ 13 กรกฎาคม พ.ศ. 2565

Raspberry pi 4 Object Detection with TensorFlow and TensorFlow lite

Raspberry pi 4B Object Detection with TensorFlow and Tensorflow Lite Comparison













What is object detection?

Given an image or a video stream, an object detection model can identify which of a known set of objects might be present and provide information about their positions within the image.

An object detection model is trained to detect the presence and location of multiple classes of objects. For example, a model might be trained with images that contain various pieces of fruit, along with a label that specifies the class of fruit they represent (e.g. an apple, a banana, or a strawberry), and data specifying where each object appears in the image.

When we subsequently provide an image to the model, it will output a list of the objects it detects, the location of a bounding box that contains each object, and a score that indicates the confidence that detection was correct.

Object Detection Models

We use MobileNet-v2 Model.

Run Object Detection Model on Raspberry pi 4B


TensorFlow

Software • Raspberry pi Legacy OS ( Raspbian 10 , 32 bit version ) • Tensorflow 1.14.0 • OpenCV 4.0 • Python 3.7.3 Machine Learning Model : SSD Mobilenet V2 ( FP32 )

Image JPG 1024x636 pixels

Video MP4 960x540 pixels

Result ( Image )


Loading time 8327.86 ms             @ test1

Inference time 10245.02 ms


Loading time: 7910.86 ms            @ test2

Inference time: 9650.78 ms


Loading time: 7917.60 ms            @ test3

Inference time: 9642.02 ms


Result ( Video )    ~ 2 fps



TensorFlow-lite

 
Result ( image )


Loading time: 4.13 ms            @ test1

Inference time: 229.85 ms


Loading time: 4.38 ms            @ test2

Inference time: 231.55 ms


Result ( Video )    ~ 4-5 fps



TensorFlow and TensorFlow-lite Comparison















Reference

TensorFlow

https://www.tensorflow.org/

https://github.com/tensorflow/models


TensorFlow-lite

https://github.com/EdjeElectronics/TensorFlow-Lite-Object-Detection-on-Android-and-Raspberry-Pi


Website : https://softpower.tech

วันศุกร์ที่ 15 พฤษภาคม พ.ศ. 2563

Raspberry pi Pytorch Object Detection

Raspberry pi Pytorch Object Detection

Single Shot MultiBox Detector Implementation in Pytorch.

Software

  • Raspbien 10
  • Python 3.7.3
  • Torch 1.4.0
  • Torchvision 0.5

Pre-trained Model : MobileNetV2 SSD-Lite

Install on Raspberry pi


Dependency 
sudo apt install libopenblas-dev libblas-dev m4 cmake cython python3-dev python3-yaml python3-setuptools python3-wheel python3-pillow python3-numpy -y



git clone https://github.com/marcusvlc/pytorch-on-rpi.git

cd pytorch-on-rpi/

sudo pip3 install torch-1.4.0a0+7f73f1d-cp37-cp37m-linux_armv7l.whl

sudo pip3 install torchvision-0.5.0a0+85b8fbf-cp37-cp37m-linux_armv7l.whl


Change Filename
 Goto.  /usr/local/lib/python3.7/dist-packages/torch 

Change

_CXXXXXXXX.so   to  _C.so
_dlXXXXXXXX.so  to    _dl.so 


cd /usr/local/lib/python3.7/dist-packages/torch

sudo mv _C.cpython-37m-arm-linux-gnueabi.so _C.so

sudo mv _dl.cpython-37m-arm-linux-gnueabi.so _dl.so

Check Version.   Goto python3 shell

>>> import torch 
>>> torch.__version__

>>> import torchvision 
>>> torchvision.__version__
Source Code
git clone https://github.com/qfgaohao/pytorch-ssd.git


Pre-Trained Model  MobileNetV2 SSD-Lite )
cd pytorch-ssd/models

wget https://storage.googleapis.com/models-hao/mb2-ssd-lite-mp-0_686.pth

wget https://storage.googleapis.com/models-hao/voc-model-labels.txt


Run demo Code


For Image file 
python3 run_ssd_example.py mb2-ssd-lite models/mb2-ssd-lite-mp-0_686.pth models/voc-model-labels.txt your_image_file




Reference


วันอาทิตย์ที่ 19 เมษายน พ.ศ. 2563

Raspberry pi TensorFlow.JS Facemesh






Raspberry pi TensorFlow.JS Facemesh

The facemesh package infers approximate 3D facial surface geometry from an image or video stream, requiring only a single camera input without the need for a depth sensor. This geometry locates features such as the eyes, nose, and lips within the face, including details such as lip contours and the facial silhouette. This information can be used for downstream tasks such as expression classification (but not for identification). Refer to our model card for details on how the model performs across different datasets. This package is also available through MediaPipe.

Performance characteristics

Facemesh is a lightweight package containing only ~3MB of weights, making it ideally suited for real-time inference on a variety of mobile devices. When testing, note that TensorFlow.js also provides several different backends to choose from, including WebGL and WebAssembly (WASM) with XNNPACK for devices with lower-end GPU's. The table below shows how the package performs across a few different devices and TensorFlow.js backends:

The table shows how the package performs across different devices and TensorFlow.js backends


Demo Source Code
https://github.com/tensorflow/tfjs-models/tree/master/facemesh




Installation on Raspberry pi ( see in Youtube )

Install NodeJS and npm

curl -sL https://deb.nodesource.com/setup_12.x | sudo bash -

sudo apt-get install nodejs


Install Yarn

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list

sudo apt-get update && sudo apt-get install yarn


Check Version



Run Demo code ( need USB Webcam )

Git Clone code
git clone https://github.com/tensorflow/tfjs-models.git


Go into the facemesh folder:
cd facemesh
Install dependencies:
yarn
Publish facemesh locally:
yarn build && yarn yalc publish
Cd into the demos and install dependencies:
cd demo
yarn
Link the local facemesh to the demos:
yarn yalc link @tensorflow-models/facemesh
Start the dev demo server:
yarn watch
Then Open Web Browser and use domain localhost:1234

Need USB Webcam







Test on Android Web Browser



       .

Reference

Face and hand tracking in the browser with MediaPipe and TensorFlow.js
https://blog.tensorflow.org/2020/03/face-and-hand-tracking-in-browser-with-mediapipe-and-tensorflowjs.html

MediaPipe
https://github.com/google/mediapipe

Online Demo