Real time Object Counting api. Implemented with the YOLO algorithm and with the SORT algorithm
The implementation is using model in same format as darkflow and darknet. Weight files, as well as cfg files can be found here. Darklow supports only YOLOv1 and YOLOv2. Support for YOLOv3 has not yet been implemented.
In order to achieve the best performance, you should have Cuda and tensorflow-gpu installed on Your device.
-tensorflow 1.0
-numpy
-opencv 3
You can choose one of the following three ways to get started with darkflow.
Just build the Cython extensions in place. NOTE: If installing this way you will have to use ./flow
in the cloned darkflow directory instead of flow
as darkflow is not installed globally.
python3 setup.py build_ext --inplace
Let pip install darkflow globally in dev mode (still globally accessible, but changes to the code immediately take effect)
pip3 install -e .
Install with pip globally
pip3 install .
The YOLO algoritym impementation used in this project requires 3 files. Configuration of network (.cfg), trained weights (.weights) and labels.txt.
YOLO implementation used in this project enables usage of YOLOv1 and YOLOv2, and its tiny versions. Support for YOLOv3 has not yet been implemented.
Configuration file determines a network architecture. Configurations can be found here. In example scripts we assume that the configuration is placed in cfg/ folder. Location of used .cfg file is specyfied in the options object used in the code.
The .cfg file can be downloaded using the following command:
wget https://raw.githubusercontent.com/pjreddie/darknet/master/cfg/yolov2.cfg -O cfg/yolov2.cfg
The .weights files contain trained parameters of a network. In example scripts we assume the weights are placed in bin/ folder. Location of used .weights file is specyfied in the options object used in the code.
The .weights file can be downloaded using the following command:
wget https://pjreddie.com/media/files/yolov2.weights -O bin/yolov2.weights
This file is list of classes detected by a YOLO netowork. It shoud contain as many classes as it is specyfied in a .cfg file.
Once You have all dependencies instaled and all required files You can start counting objects. Object counting is carried out by an ObjectCuntingAPI object.
Examples of counting below
python3 count_cars_crosing_virtual_line.py
python3 count_objects_from_camera.py
python3 count_people_on_image.py
The following open source projects were used in the implementation
The YOLO algorithm impementation - Darkflow
Object counting with YOLO and SORT. Similar project, but instead of using the darklow YOLO implementation, it uses the opencv YOLO implementation, so there is no GPU acceleration.
Object tracking and counting - SORT
Highway surveillance video
Pedestrian surveillance video
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details
That's all.