[PYTHON] Let's try real-time object detection using Faster R-CNN

Introduction

So far, we have introduced methods such as BING and Selective Search as R-CNN. ・ Click here for past articles I tried using BING with OpenCV as pre-processing for CNN I tried using Selective search as R-CNN However, the accuracy of BING is not very good, There are still complaints about Selective Search, such as slow processing speed. So this time I would like to try Faster R-CNN.

What is Faster R-CNN?

It is a method that has been accelerated by detecting object candidates with CNN. Originally, a method called Fast R-CNN was announced earlier, Soon after, the faster Faster R-CNN was announced. (The speed of progress in this world is terrifying.) For details, please refer to the Cornnel University page. https://arxiv.org/abs/1506.01497

manner

The original is Caffe https://github.com/rbgirshick/py-faster-rcnn/tree/96dc9f1dea3087474d6da5a98879072901ee9bf9 I don't want to use Caffe very much as a personal hobby, so this time I will use the Chainer version. https://github.com/mitmul/chainer-faster-rcnn

Environment: Ubuntu16.04LTS, Python2.7.12, Chainer1.12.0 Just follow the steps in the ReadMe.

□ Clone chainer-fast-neural style.

$ git clone https://github.com/mitmul/chainer-faster-rcnn

□ Go to the library folder and build

$ cd chainer-faster-rcnn/lib
$ python setup.py build_ext -i
$ cd ..

□ Download the trained model

$ if [ ! -d data ]; then mkdir data; fi; cd data
$ wget https://dl.dropboxusercontent.com/u/2498135/faster-rcnn/VGG16_faster_rcnn_final.model`
$ cd ..

□ Download and run the test image

$ wget http://vision.cs.utexas.edu/voc/VOC2007_test/JPEGImages/004545.jpg
$ python forward.py --img_fn 004545.jpg --gpu 0

result

It is the result of the test image result_master.jpg This is an image I prepared myself result_dog.jpg Both are detected accurately. Furthermore, when using GTX970, it is detected in about 0.3 to 0.4 seconds. By the way, it took about 30 seconds for CPU only.

Summary

Faster R-CNN seems to be a pretty good technique at the moment. A graphics board is required. In the future, there will be lightweight models that will work on mobile devices as well.

[2016/11/30 postscript] If you think about it, there seems to be a faster method called Single Shot Multi-box Detection. https://arxiv.org/abs/1512.02325 I would like to try this in my spare time as well.

Recommended Posts

Let's try real-time object detection using Faster R-CNN
Try real-time object recognition using YOLOv2 (TensorFlow)
Let's try neural machine translation using Transformer
Let's try real-time object detection using Faster R-CNN
Logo detection using TensorFlow Object Detection API
Object detection using Jetson Nano (YOLOv3)-(1) Jetson Nano settings-
Try Object detection with Raspberry Pi 4 + Coral
Let's try neural machine translation using Transformer
[Python] Real-time object detection with iPad camera
I tried object detection using Python and OpenCV
Try using Tkinter
Try using docker-py
Try using cookiecutter
Try using PDFMiner
Try using geopandas
Try using Selenium
Try using scipy
Try using pandas.DataFrame
Try using django-swiftbrowser
Try using matplotlib
Try using tf.metrics
Try using PyODE
Try face detection in real time using a webcam
[Summary] Object detection model "End-to-End Object Detection with Transformers" using Transformer