Darknet is an open source neural network framework written in C and CUDA. It is fast, easy to install, and supports CPU and GPU computation. For more information see the Darknet project website.
YOLO V2 doesn't have default support for handling image as numpy array. For that, you may need to edit some of the source files, and add NUMPY
flag to your Makefile
. This wrapper covers all those headaches. Follow the instructions and you're good to go.
- Clone the repository
git clone https://github.com/sleebapaul/yolov2-numpy-wrapper.git
- Get into the root folder
cd yolov2-numpy-wrapper
- Compile (Notice the
NUMPY=1
flag. You can compile withCUDA
,CUDNN
andOPENCV
if you would like to, by turning their flag value from 0 to 1.)
make
- Download the weights (YOLO V2 weights are currently not available at official site as they've updated everything V2 to V3. YOLO V2 site is kept alive but source code and weights are again for V3.)
wget https://www.dropbox.com/s/hvn3qk254wuf0nf/yolov2.weights
- Run the example python script to count cars using OpenCV.
Notice the numpy array to YOLO IMAGE object conversion using
ndarray_image = lib.ndarray_to_image
ndarray_image.argtypes = [POINTER(c_ubyte), POINTER(c_long), POINTER(c_long)]
ndarray_image.restype = IMAGE
Then functions nparray_to_image
and detect_np
can handle the numpy arrays for detection.
python3 car_counter.py
The source code and Makefile edits are followed from here.