วันอาทิตย์ที่ 28 ตุลาคม พ.ศ. 2561

Raspberry pi YOLO Real-time Object Detection





Raspberry pi YOLO Real-time Object Detection

You only look once (YOLO) is a state-of-the-art, real-time object detection system.

How It Works

Prior detection systems repurpose classifiers or localizers to perform detection. They apply the model to an image at multiple locations and scales. High scoring regions of the image are considered detections.
We use a totally different approach. We apply a single neural network to the full image. This network divides the image into regions and predicts bounding boxes and probabilities for each region. These bounding boxes are weighted by the predicted probabilities.
Our model has several advantages over classifier-based systems. It looks at the whole image at test time so its predictions are informed by global context in the image. It also makes predictions with a single network evaluation unlike systems like R-CNN which require thousands for a single image. This makes it extremely fast, more than 1000x faster than R-CNN and 100x faster than Fast R-CNN. See our paper for more details on the full system.

What's New in Version 2?

YOLOv2 uses a few tricks to improve training and increase performance. Like Overfeat and SSD we use a fully-convolutional model, but we still train on whole images, not hard negatives. Like Faster R-CNN we adjust priors on bounding boxes instead of predicting the width and height outright. However, we still predict the x and y coordinates directly. The full details are in our paper.!


So,we've test run Yolov2 on 

  1. Raspberry pi only 
  2. Raspberry pi with intel movidius ( Neural Compute Stick )




Run on Raspberry pi


Install darknet yolov2

git clone https://github.com/pjreddie/darknet
cd darknet
make


Download tiny-yolov2 weights

wget https://pjreddie.com/media/files/yolov2-tiny-voc.weights


Run Code
./darknet detector test cfg/voc.data cfg/yolov2-tiny-voc.cfg yolov2-tiny-voc.weights data/dog.jpg

./darknet detector test cfg/voc.data cfg/yolov2-tiny-voc.cfg yolov2-tiny-voc.weights data/dog.jpg

Result




Process time = 32.36 sec.




Run on Raspberry pi with Intel Movidius ( Neural Compute Stick )

This project shows how to run tiny yolov2 (20 classes) with movidius stick:
  • A python convertor from yolo to caffe
  • A c/c++ implementation and python wrapper for region layer of yolov2
  • A sample for running yolov2 with movidius stick in images or videos

Install NCSDK 2.0 ( see this )
https://raspberrypi4u.blogspot.com/2018/10/install-intel-movidius-neural-compute-sdk.html


Install YOLOv2NCS
git clone https://github.com/duangenquan/YoloV2NCS.git

then make
cd YoloV2NCS
make

Convert Caffe to NCS
mvNCCompile ./models/caffemodels/yoloV2Tiny20.prototxt -w ./models/caffemodels/yoloV2Tiny20.caffemodel -s 12

Run Python Code
python3 ./detectionExample/Main.py --image ./data/dog.jpg

Result



Process time = 571 ms.


Reference

https://pjreddie.com/darknet/yolov2/
https://github.com/duangenquan/YoloV2NCS

How computers learn to recognize objects instantly | Joseph Redmon

https://www.youtube.com/watch?v=Cgxsv1riJhI

YOLO Object Detection (TensorFlow tutorial)

https://www.youtube.com/watch?v=4eIBisqx9_g


My Website
email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400


วันอังคารที่ 23 ตุลาคม พ.ศ. 2561

Intel® Movidius™ Neural Compute SDK Example Code on Raspberry pi

Intel® Movidius™ Neural Compute SDK Example code on Raspberry pi



Neural Compute Application Zoo (NC App Zoo)


The NC App Zoo is a community repository with many content owners and maintainers. All NC App Zoo content is being made available here in a central location for others to download, experiment with, modify, build upon, and learn from.

git clone -b ncsdk2 https://github.com/movidius/ncappzoo.git

The NC App Zoo contains the following top-level directories. See the README file in each of these directory or just click on the links below to explore the contents of the NC App Zoo.
  • apps : Applications built to use the Intel Movidius NCS. This is a great place to start in the NC App Zoo!
  • caffe : Scripts to download caffe models and compile graphs for use with the NCS
  • tensorflow : Scripts to download TensorFlow™ models and compile graphs for use with the NCS
  • data : Data and scripts to download data for use with models and applications that use the NCS

Image Classification Applications

Image classification applications typically use one of the image classification networks in the repository to classify an image as to it's likeliness to be in each of the classes on which a network was trained. For a step by step tutorial on how to build an image classification network look at Build an Image Classifier in 5 steps at the Intel® Movidius™ Neural Compute Stick Blog
Image Classification ApplicationDescription++++++Thumbnail++++++
image-classifier

*Canonical Image Classification Example
Python
Multiple Networks
Project that accompanies the blog https://movidius.github.io/blog/ncs-image-classifier/.. If you are getting started with image classification this is a good first stop.
MultiStick_GoogLeNetPython
Caffe GoogLeNet
Image classification on multiple devices. Shows scalability by using one GUI window to show inferences on a single stick and another window to show multiple sticks
MultiStick_TF_InceptionPython
TensorFlow Inception
Image classification on multiple devices.
classifier-guiPython
Multiple Network
GUI to select network and image to classify.
gender_age_lbpC++
Caffe AgeNet, GenderNet
Uses AgeNet and GenderNet to predict age and gender of people in a live camera feed. The camera feed is displayed with a box overlayed around the faces and a label for age and gender of the person. The face detection is done with OpenCV.
live-image-classifierPython
Multiple Networks
Performs image classification on a live camera feed. This project was used to build a battery powered, RPi based, portable inference device (although RPi isn't required.) You can read more about this project at this NCS developer blog https://movidius.github.io/blog/battery-powered-dl-engine/.
log-image-classifierPython
Multiple Networks
Application logs results of an image classifier into a comma-separated values (CSV) file. Run inferences sequentially (and recursively) on all images within a folder.
rapid-image-classifierPython
Multiple Networks
Performs image classification on a large number of images. This sample code was used to validate a Dogs vs Cats classifier built using a customized version of GoogLeNet. You can read more about this project (and a step-by-step guide) here https://movidius.github.io/blog/deploying-custom-caffe-models/.
stream_inferPython
Caffe SqueezeNet
Uses gstreamer to grab frames from a live camera stream and run inferences on them while displaying top results in real time.
video_face_matcherPython
TensorFlow FaceNet
Uses the tensorflow/FaceNet network to identify faces in a camera video stream. A single face image is used as the key and when a face in the video stream matches the key, a green frame is overlayed on the video feed.
video_face_matcher_multipleFacePython
TensorFlow FaceNet
Similar to the video_face_matcher application but supports matching multiple faces
topcoder_examplePython
Multiple Networks
Contains all supporting files needed to generate submissions.zip file, which would then be uploaded to the TopCoder leaderboard for automatic scoring of the NCS competition described here: https://developer.movidius.com/competition. This program may be useful as a reference for doing accuracy calculations.

Object Detection Applications

Object detection appliations make use of one of the object detection networks in the repository to detect objects within an image. The object detection networks typically determine where objects are within the image as well as what type of objects they are.
Object Detection ApplicationDescription+++++Thumbnail+++++
birdsPython
Caffe Tiny Yolo, GoogLeNet
Detects and identifies birds in photos by using Yolo Tiny to identify birds in general and then GoogLeNet to further classify them. Displays images with overlayed rectangles bird classification.
stream_ty_gnPython
Caffe Tiny Yolo, GoogLeNet
Sends frames of live camera stream to Tiny Yolo for object detection and then crops each object and sends that to GoogLeNet for further classification. This application requires two NCS devices, one for each network. Look at this example for straight forward example, but look at the threaded version if you are interested in better performance.
stream_ty_gn_threadedPython
Caffe Tiny Yolo, GoogLeNet
Sends frames of live camera stream to Tiny Yolo for object detection and then crops each object and sends that to GoogLeNet for further classification. This application requires two NCS devices, one for each network. This is a threaded, better performing, and slightly more complex version of the stream_ty_gn application.
street_camPython
Caffe TinyYolo, GoogLeNet
Processes a video file (presumably produced by a street camera) and overlays boxes and labels around the objects detected. Objects are detected by Tiny Yolo and then further classified by GoogLeNet. This requires two NCS devices. Look at this example for straight forward example, but look at the threaded version if you are interested in better performance.
street_cam_threadedPython
Caffe TinyYolo, GoogLeNet
Processes a video file (presumably produced by a street camera) and overlays boxes and labels around the objects detected. Objects are detected by Tiny Yolo and then further classified by GoogLeNet. This requires two NCS devices. This is a threaded, better performing, and more complex version of the street_cam application.
video_objectsPython
Caffe SSD MobileNet
Processes a video file and overlays boxes and labels around the objects detected and displays results in a GUI as frames are available.

Misc Applications

Miscellaneous applications use the NCSDK in various ways that don't fit into any of the above categories but can still be interesting.
Misc ApplicationDescription+++++Thumbnail+++++
benchmarkncsPython
Multiple Network
Outputs FPS numbers for networks in the repository that take images as input. If multiple NCS devices are plugged in will give numbers for one device and for multiple.
hello_ncs_cppC++
No Networks
Simple example demonstrating how compile, run, as well as open and close a device in C++ application.
hello_ncs_pyPython
No Networks
Simple example demonstrating how open and close a device in Python and run the program.
multistick_cppPython
Caffe SqueezeNet, GoogLeNet
Simple example demonstrating how to use multiple devices and networks in a C++ application.

Run Demo

Image Classifier


Image Classifier with Python GUI 


Video Objects Detection



Reference



My Website
email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400

วันศุกร์ที่ 12 ตุลาคม พ.ศ. 2561

Install intel® Movidius™ Neural Compute SDK on Raspberry pi

Install intel® Movidius™ Neural Compute SDK on Raspberry pi

What is Intel Movidius Neural Compute Stick?





Before Install


You will likely need to increase the swapfile size on the Raspberry Pi in order to successfully complete NCSDK and/or OpenCV installation. To increase the swapfile size, edit the value of CONF_SWAPSIZE in /etc/dphys-swapfile:
sudo nano /etc/dphys-swapfile
The default value is 100 (MB). We recommend that you change this to 1024 (MB) or greater.
Then restart the swapfile service:
sudo /etc/init.d/dphys-swapfile restart
Proceed with installation as shown above. After you have installed the NCSDK (and optionally OpenCV), you should change the swapfile size back to 100 MB.

Install

To perform the typical installation of the NCSDK, use the following commands on your host machine:

ncsdk2 (lasted V2.08.01 2018-10-04 ) Newest Version!!!

git clone -b ncsdk2 http://github.com/Movidius/ncsdk
cd ncsdk
make install


ncsdk 2 ( 09 2018 ) Old Version !!!
wget https://ncs-forum-uploads.s3.amazonaws.com/ncsdk/ncsdk-02_05_00_02-full/ncsdk-2.05.00.02.tar.gz

tar xvf ncsdk-2.05.00.02.tar.gz

cd ncsdk-2.05.00.02

make install

make examples


Install Done







Set Python path 

export PYTHONPATH="${PYTHONPATH}:/opt/movidius/caffe/python"

source ~/.bashrc

echo $PYTHONPATH
:/opt/movidius/caffe/python



Example Code 


make examples
It take 2-3 Hours

make examples OK ( no any errors )


Test Python Example Code 

Run Python code   hello_ncs.py


Run Demo

Image Classification


Image Classifier with Python GUI 


Video Objects Detection

Reference

https://software.intel.com/en-us/neural-compute-stick/get-started
https://github.com/movidius/ncappzoo/


My Website
email : info@softpowergroup.net  ,amphancm@gmail.com  Tel .+6681-6452400