This repository is about a person detection using yolov4-tiny-tflite.
It doesn't include how to train your custom dataset, but only the pretrained weights
for detecting person class
only.
Check the requirements.txt
to install requested packages, or run like below:
~$ pip install -r requirements.txt
- run the code like below
- the input arguments can be changed by yourself
~$ python run_person_detector.py --image ./data/persons.jpg --score 0.75
- run the code like below
- the input arguments can be changed by yourself
~$ python run_webcam_person_detector.py --score 0.75
- with DeepSORT tracker
~$ python run_webcam_yolov4_DeepSORT.py --score 0.75
Even though there is not a code to train yolov4-tiny, let me describe how I got the trained weights with my custom dataset:
- Achieve custom dataset from YouTube videos (using
AVA
dataset) - Train yolov4-tiny to detect only person class using the
Darknet
with the custom dataset - Convert the trained
Darknet
model totensorflow lite
model - Make the inference codes like this repository for my own application
Go to [ref5], then you can get to know how to prepare a custom dataset, which consists of only persons. AVA
dataset has been used for multiple application tasks, but I only used this for getting person images
with bounding box labels.
I got the idea that training person detector and uploading on my edge device from roboflow blog, here. They supply various and useful tools for data preprocessing, however, it's not free for massive datasets. Furthermore, I couldn't know how to set up my dataset
for training yolov4-tiny
just reading the blog.
So, I found out another awesome post in medium (hear). I followed the whole instruction of the post in order to train my model. Consequently, I trained my model using google colab
.
After training own darknet yolov4-tiny
model, we finally need to convert the darknet model to Tensorflow one. This is pretty much easy if you following this github well.
- [
Darknet.weights
] → [.tflite
]
If you succeed to take the weight file in .tflite
format, we're ready to build an inference code for person detection using Tensorflow lite.
I built two inference codes; one for image input and another for webcam video input. These codes are referred to the original inference codes here; detect.py
and detectvideo.py
.
(New)The above training processes is uploaded in this repository
[1] TRAIN A CUSTOM YOLOv4-tiny OBJECT DETECTOR USING GOOGLE COLAB / yolov4-tiny 학습 방법은 여기를 참고.
[2] How to Train a Custom Mobile Object Detection Model (with YOLOv4 Tiny and TensorFlow Lite) / YOLOv4-Tiny 로 학습한 모델을 TensorFlow Lite 로 바꿔보기 (블로그).
[3] tensorflow-yolov4-tflite, github / 이걸 참고해서 Darknet 모델을 tensorflow lite 모델로 바꿈.
[4] Yolo v4, v3 and v2 for Windows and Linux, github / yolov4-tiny 학습 코드는 여기걸 참고
[5] AVA Dataset Processing for Person Detection, github / Person detection용 학습데이터 얻는 방법 (이걸로 DB를 구축함).
[a] theAIGuysCode, tensorflow-yolov4-tflite, github / (ref3)을 참고한 레포지토리
[b] Object Detection and Tracking in 2020, netcetera blog / Detection 모듈과 Tracking 모듈을 조합할 때 참고하자
[c] Real-time Human Detection in Computer Vision - Part2, medium / 사람 감지 모듈을 만들 때 생각해볼 수 있는 파이프라인 소개
[d] Object detection and tracking in PyTorch, towarddatascience / 심플한 튜토리얼 코드 제공
[e] Object Detection and Tracking, MediaPipe / Google MediaPipe의 경우에도 Object detection을 위한 ML inference 모듈과 Box Tracking 모듈을 조합해서 프로세싱에 효율성을 더함. 이렇게 구성하면 매 프레임마다 detection inference를 할 필요가 없어진다.
[f] Object-Detection-and-Tracking, github / YOLOv4 + Deep_SORT 의 조합 예시코드 참고 (강력 추천)