This is my Keras implementation of YOLOv3 (Tensorflow backend) that is based on qqwweee/keras-yolo3. So far I have only implemented detection. I am working on the code for training. My goal is to have an elegant implementation of YOLOv3 in Keras for my upcoming undergraduate course on Artificial Intelligence in Fall 2019.
I have made several improvements:
- I have written a Lambda layer for decoding the output produced by the YOLOv3 model (it is no longer necessary to run a tensorflow session as in qqwweee's implementation).
- I have also implemented a (fast) non-maximum-suppression based on jrosebr1/imutils. To speed-up nms, I drop boxes with lower confidence and exit as soon as maximum number of boxes obtained.
- I use opencv instead of PIL.
- I have used tensor names
that are as close as possible to the names used in the paper
YOLOv3: An Incremental Improvement. Compare section 2.1
Bounding Box Prediction/Figure 2 and the implementation of the function
make_decoder_layer
inyolov3\model.py
.
- Download YOLOv3 weights
yolov3.weights
from YOLO website. - Convert the Darknet YOLOv3 model to a Keras model:
python convert.py yolov3.cfg yolov3.weights model_data/yolov3.h5
- Run YOLOv3 detection:
python detection.py --image <path to image>
orpython detection.py --video <path to video>
. (Note that it takes a while to load the Keras modelmodel_data\yolov3.h5
before the detection starts.)
Click on the image below to see this implementation in action: