Try to detect an object with Raspberry Pi ~ Part 1: Comparison of detection speed ~

Introduction

When performing object detection with Raspberry Pi, I compared the detection speed and detection accuracy of each source of YOLO (You only look once), which is one of the main object detection methods, so I will summarize it.

Regarding the mechanism of YOLO, it was easy to understand [History of object detection method: Introduction of YOLO].

What I want to do with a Raspberry Pi

As a pet camera for cats, I want to distinguish between four cats! The pattern is different for all four! I only think about what to distinguish and what to do, such as monitoring the state of the cat and controlling the remote control of the air conditioner, or looking at the amount of activity and using it for health management.

--MUST: You can change the number of classes to identify and create your own learning model (outside the scope of this article). --MAY: I want to judge once a second if possible

environment

![RaspberryPi-RaspberryPi4 ModelB (4GB)](https://img.shields.io/badge/Raspberry Pi-RaspberryPi4 ModelB (4GB) --brightgreen)![OS-Raspbian 32bit (2020.5.27 version)](https:: //img.shields.io/badge/OS-Raspbian 32bit (2020.5.27 version) --brightgreen)

result

The evaluation target is the COCO dataset (80 classes), YOLO author's site: YOLO: Real-Time Object Detection and [AlexeyAB](https:: //github.com/AlexeyAB/darknet) uses the weights of the trained model distributed. Each model has a "Tiny" that prioritizes detection time.

Below is the result of Source x Model. The explanation, the image of the result, and the impression will be described later.

Source Model Detection time Detection accuracy
pjreddie v2 477 seconds
pjreddie v2-Tiny 42 seconds ×
AlexeyAB v2 33 seconds
AlexeyAB v2-Tiny 6.6 seconds
AlexeyAB v3 74 seconds
AlexeyAB v3-Tiny 6.7 seconds
AlexeyAB v4 152 seconds
AlexeyAB v4-Tiny 7.8 seconds
keras-yolo3 v3 12 seconds
keras-yolo3 v3-Tiny 0.75 seconds
Tensorflow-YOLOv3 v3 8.9 seconds
Tensorflow-YOLOv3 v3-Tiny 3.4 seconds
yolov3-tf2 v3 5.6 seconds
yolov3-tf2 v3-Tiny 0.67 seconds

The detection accuracy is subjective, but it is based on the recognition rate of the main object in each image. ◎ (90% -100%), 〇 (70% -90%), △ (50% -70%), × (unrecognizable).

Explanation / result image / impression for each source

pjreddie/darknet https://pjreddie.com/ https://github.com/pjreddie/darknet

gcc-8.3.0 (Raspbian 8.3.0-6+rpi1)

Model dog person
v2 predictions_v2_dog.jpg predictions_v2_person.jpg
v2-tiny predictions_v2t_dog.jpg predictions_v2t_person.jpg

AlexeyAB/darknet https://github.com/AlexeyAB/darknet

--The inherited version of pjreddie. Compatible with YOLO v4. --You can download the weights of the trained model of YOLO v4 from here. --C language --It is possible to run it on GPU by changing the parameters of the make file, but it is difficult with Raspberry Pi. --The CPU usage rate during object detection is transitioning from 25 to 35%, and the CPU usage efficiency is poor.

gcc-8.3.0 (Raspbian 8.3.0-6+rpi1)

Model dog person
v2 predictions_v2_dog.jpg predictions_v2_person.jpg
v2-tiny predictions_v2t_dog.jpg predictions_v2t_person.jpg
v3 predictions_v3_dog.jpg predictions_v3_person.jpg
v3-tiny predictions_v3t_dog.jpg predictions_v3t_person.jpg
v4 predictions_v4_dog.jpg predictions_v4_person.jpg
v4-tiny predictions_v4t_dog.jpg predictions_v4t_person.jpg

qqwweee/keras-yolo3 https://github.com/qqwweee/keras-yolo3

--keras version --You can convert and use pjreddie / darknet weights. --Since the image of the detection result cannot be output by default, the processing was added by referring to I moved YOLO-v3 of Keras. --The CPU usage rate during object detection is 100%

Keras-2.2.5tensorflow-1.13.1Python-3.7.3

Model dog person
v3 out_v3_dog.jpg out_v3_person.jpg
v3-tiny out_v3t_dog.jpg out_v3t_person.jpg

neuralassembly/Tensorflow-YOLOv3 https://github.com/neuralassembly/Tensorflow-YOLOv3 Try object detection with YOLO v3-Tiny / YOLO v3 on Raspberry Pi

--Tensorflow 1 series --You can convert and use pjreddie / darknet weights. --Since the detection time is not output, measure the time before and after sess.run (). --The CPU usage rate during object detection is 100%

tensorflow-1.13.1Python-3.7.3

Model dog person
v3 image_output_v3_dog.png image_output_v3_person.png
v3-tiny image_output_v3t_dog.png image_output_v3t_person.png

zzh8829/yolov3-tf2 https://github.com/zzh8829/yolov3-tf2

--tensorflow2 system (using tf.keras) --You can convert and use pjreddie / darknet weights. --In RaspberryPi, pip install tensorflow did not include tensorflow2, so download and install tensorflow-2.2.0-cp37-cp37m-linux_armv7l.whl from https://github.com/PINTO0309/Tensorflow-bin. --CPU usage during object detection is 75-85%

tensorflow-2.2.0Python-3.7.3

Model dog person
v3 output_v3_dog.jpg output_v3_person.jpg
v3-tiny output_v3t_dog.jpg output_v3t_person.jpg

Summary

――To satisfy "I want to judge once a second", the detection accuracy drops a little, but it is difficult only with Python v3-tiny. ――When I use it, the number of classes will be small, so I hope that it will improve the accuracy.

Our goal

--For learning, build Alexey AB on the GPU version and run it on Google Colaboratory. 1000 epochs for Tiny: about 7 minutes. ――For object detection, decide which one to use based on the ease of diversion from the Python system. (Is zzh8829 / yolov3-tf2 safe considering the future?) ――I have to take a picture of the cat. ..

reference

Using Darknet with Raspberry Pi YOLOv3 dissertation translation

qqwweee/keras-yolo3 -I tried object detection with YOLO (keras-yolo3)! -I moved YOLO-v3 of Keras -Engineer's sleepless night [object detection] how to use keras-yolo3

zzh8829/yolov3-tf2 -Use yolov3-tf2 to easily try real-time object detection. / Tensorflow v2 ・ keras

Recommended Posts

Try to detect an object with Raspberry Pi ~ Part 1: Comparison of detection speed ~
Try Object detection with Raspberry Pi 4 + Coral
Try to visualize the room with Raspberry Pi, part 1
I tried to detect an object with M2Det!
I tried to build an environment of Ubuntu 20.04 LTS + ROS2 with Raspberry Pi 4
Image analysis with Object Detection API to try in 1 hour
Try moving 3 servos with Raspberry Pi
I tried to automate the watering of the planter with Raspberry Pi
Let's make an IoT shirt with Lambda, Kinesis, Raspberry Pi [Part 1]
Try fishing for smelt with Raspberry Pi
How to put OpenCV in Raspberry Pi and easily collect images of face detection results with Python
Try speed comparison of BigQuery Storage API
Operate an oscilloscope with a Raspberry Pi
Try to generate an image with aliasing
I made an npm package to get the ID of the IC card with Raspberry Pi and PaSoRi
Try to separate the background and moving object of the video with OpenCV
[Verification] Try to align the point cloud with the optimization function of pytorch Part 1
Try to use up the Raspberry Pi 2's 4-core CPU with Parallel Python
CSV output of pulse data with Raspberry Pi (CSV output)
Get CPU information of Raspberry Pi with Python
Connect to MySQL with Python on Raspberry Pi
Try to detect fish with python + OpenCV2.4 (unfinished)
Measure CPU temperature of Raspberry Pi with Python
[Cloud9] Try to build an environment with django 1.11 of Python 3.4 without understanding even 1 mm
Stop sign detection Development of visualization part part5 Display what was detected when an object was detected
Easy IoT to start with Raspberry Pi and MESH
Try debugging Python on Raspberry Pi with Visual Studio.
Detect mask wearing status with OpenCV and Raspberry Pi
Take the value of SwitchBot thermo-hygrometer with Raspberry Pi
Log the value of SwitchBot thermo-hygrometer with Raspberry Pi
Try to get the contents of Word with Golang
Make an umbrella reminder with Raspberry Pi Zero W
Face detection from images taken with Raspberry Pi camera
Let's operate GPIO of Raspberry Pi with Python CGI
Until you annotate your own dataset and detect an object with EfficientDet ~ Character face detection ~
Make a note of what you want to do in the future with Raspberry Pi
I tried to move ROS (Melodic) with the first Raspberry Pi (Stretch) at the beginning of 2021
I tried to make a motion detection surveillance camera with OpenCV using a WEB camera with Raspberry Pi
GPGPU with Raspberry Pi
DigitalSignage with Raspberry Pi
Easy introduction to home hack with Raspberry Pi and discord.py
Application of affine transformation by tensor-from basic to object detection-
Update Python for Raspberry Pi to 3.7 or later with pyenv
Play with the Raspberry Pi Zero WH camera module Part 1
An introduction to object orientation-let's change the internal state of an object
I tried running Movidius NCS with python of Raspberry Pi3
Create an LCD (16x2) game with Raspberry Pi and Python
Make an air conditioner integrated PC "airpi" with Raspberry Pi 3!
Production of temperature control system with Raspberry Pi and ESP32 (1)
Try to automate the operation of network devices with Python
Attempt to automatically adjust the speed of time-lapse movies (Part 2)
Connect Raspberry Pi to Alibaba Cloud IoT Platform with Python
I sent the data of Raspberry Pi to GCP (free)
Try to extract the features of the sensor data with CNN
List of things you might need to do to develop OBD Linux on Raspberry Pi with Buildroot
Measure temperature, humidity, etc. with SensorTag and send it to Ambient via Raspberry Pi 3 to graph it Part 2