TensorFlow implementation of the YOLO (You Only Look Once)
This project is deprecated. Please see yolo2-pytorch
Configurations are mainly defined in the "config.ini" file. Such as the detection model (config/model), base directory (config/basedir, which identifies the cache files (.tfrecord), the model data files (.ckpt), and summary data for TensorBoard), and the inference function ([model]/inference). Notability the configurations can be extended using the "-c" command-line argument.
Download the PASCAL VOC 2007 (training, validation and test) and 2012 (training and validation) dataset. Extract these tars into one directory (such as "~/Documents/Database/").
Download the COCO 2014 (training, validation, and test) dataset. Extract these zip files into one directory (such as "~/Documents/Database/coco/").
Run "cache.py" to create the cache file for the training program. A verify command-line argument "-v" is strongly recommended to check the training data and drop the corrupted examples, such as the image "COCO_val2014_000000320612.jpg" in the COCO dataset.
Run "train.py" to start the training process (the model data saved previously will be loaded if it exists). Multiple command-line arguments can be defined to control the training process. Such as the batch size, the learning rate, the optimization algorithm and the maximum number of steps.
Run "detect.py" to detect objects in an image. Run "export CUDA_VISIBLE_DEVICES=" to avoid out of GPU memory error while the training process is running.
python3 cache.py -c config.ini config/yolo2/darknet-20.ini -v
Download a 80 classes Darknet YOLOv2 model (the original file name is "yolo.weights", a version from Darkflow is recommanded). In this tutorial I put it in "~/Downloads/yolo.weights".
Parse the 80 classes Darknet YOLOv2 model into Tensorflow format (~/Documents/Database/yolo-tf/yolo2/darknet/80/model.ckpt). A warning like "xxx bytes remaining" indicates the file "yolo.weights" is not compatiable with the original Darknet YOLOv2 model (defined in the function model.yolo2.inference.darknet
). Make sure the 80 classes data is cached before parsing.
python3 parse_darknet_yolo2.py ~/Downloads/yolo.weights -c config.ini config/yolo2/darknet-80.ini -d
python3 train.py -c config.ini config/yolo2/darknet-20.ini -t ~/Documents/Database/yolo-tf/yolo2/darknet/80/model.ckpt -e yolo2_darknet/conv -d
tensorboard --logdir ~/Documents/Database/yolo-tf/yolo2/darknet/20
python3 train.py -c config.ini config/yolo2/darknet-20.ini -b 16
python3 detect.py $IMAGE_FILE -c config.ini config/yolo2/darknet-20.ini
python3 detect_camera.py -c config.ini config/yolo2/darknet-20.ini
This project is released as the open source software with the GNU Lesser General Public License version 3 (LGPL v3).
This project is mainly inspired by the following projects: