Real-Time Object Detection with YOLO v2 Using GPU Coder
Walk through an example of real-time object detection using YOLO v2 in MATLAB®. We start with a published example in MATLAB that explains how to train a YOLO v2 object detector and, using GPU Coder™, we generate optimized CUDA code.
We verify the generated code by compiling it into a MEX file using nvcc and we find the generated MEX to run at about 80 frames per second on the test video file.
Using the hardware support package for NVIDIA® GPUs, we deploy the generated code to the Jetson Xavier board as a standalone application.
Published: 28 Mar 2019
Hi, I am Ram Cherukuri, product manager here at Mathworks, and in this video I am going to walk you through an example of real-time object detection using Yolo V2 in MATLAB.
What is Yolo?
YOLO stands for “You only look once” and it is a popular approach for object detection.
A common approach to object detection was to repurpose classifiers to perform detection.
So, for instance, RCNN uses region proposal methods to first generate potential bounding boxes in an image and then run a classifier on these proposed boxes and then refine the predictions. As you can see, this requires multiple evaluations.
Yolo, on the other hand, frames detection as a regression problem, and unifies the separate components of object detection into a single neural network.
It divides the input image into a grid and each grid cell predicts a certain number of bounding boxes along with confidence scores for the boxes. The scores reflect how confident the model is that the box contains an object and also how accurate it thinks the box is that it predicts. Each grid cell also predicts conditional class probabilities.
That’s a lot to process and I would suggest referring to a few papers and articles to understand the nuances of this unique approach as it’s not possible to cover all that in this short video.
Yolo has become very popular and important as it is considered the state-of-the-art technique since it uses a single network and is very fast for real-time object detection.
Even if you are not familiar, you can get started with Yolo v2 with this published example in MATLAB® that explains how you can train a Yolov2 object detector on your data.
Then, using GPU Coder™, you can generate optimized CUDA code to target NVIDIA® boards like the Jetson Xavier directly from MATLAB.
The hardware support package enables you to deploy the generated code to the Jetson and the drive platforms, as we will see in the demo that follows.
Here in MATLAB, I have taken the trained object detector from the example as my starting point and I am going to run inference on a test image here.
In fact, we ran a simple test comparing the Faster RCNN model with Yolo v2 and you can see that Yolo v2 is about 25 times faster on my local machine here.
Now, using GPU Coder, we are going to generate CUDA code from this function and compile it using nvcc into a MEX file so we can verify the generated code on my desktop machine.
You can see that the generated MEX runs at about 80 frames per sec on this video file on my desktop that has a Titan Xp GPU.
Please note that these are not official benchmarking numbers, as I have some other programs also running in the background, but this should give you an idea of the performance of the Yolo v2 network.
Now, using the hardware support package for NVIDIA GPUs, I can get live data from the camera connected to my Jetson Xavier board and we can run inference using the same generated MEX file.
Here I am using the live data from outside my window overlooking the traffic on Route 9.
Finally, I can generate code from our algorithm here that takes the input from the webcam, uses Yolo v2 for object detection, and displays the output.
The NVIDIA hardware support package supports code generation for these interfaces and once code is generated and built, we can run the executable as a standalone application on the Jetson Xavier board.
So, we have real-time object detection using Yolo v2 running standalone on the Jetson Xavier here, taking live input from the webcam connected to it.
A few takeaways from this example are summarized here. You can target NVIDIA boards like the Jetson Xavier and Drive PX with simple APIs directly from MATLAB without needing to write any CUDA code.
Please refer to the links below the video to learn more about the hardware support package and to find more object detection examples in MATLAB.
Featured Product
GPU Coder
Up Next:
Related Videos:
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)