// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt /* This is an example illustrating the use of the deep learning tools from the dlib C++ Library. I'm assuming you have already read the dnn_introduction_ex.cpp, the dnn_introduction2_ex.cpp and the dnn_introduction3_ex.cpp examples. In this example program we are going to show how one can train a YOLO detector. In particular, we will train the YOLOv3 model like the one introduced in this paper: "YOLOv3: An Incremental Improvement" by Joseph Redmon and Ali Farhadi. This example program will work with any imglab dataset, such as: - faces: http://dlib.net/files/data/dlib_face_detection_dataset-2016-09-30.tar.gz - vehicles: http://dlib.net/files/data/dlib_rear_end_vehicles_v1.tar Just uncompress the dataset and give the directory containing the training.xml and testing.xml files as an argument to this program. */ #include #include #include #include #include #include using namespace std; using namespace dlib; // In the darknet namespace we define: // - the network architecture: DarkNet53 backbone and detection head for YOLO. // - a helper function to setup the detector: change the number of classes, etc. namespace darknet { // backbone tags template using btag8 = add_tag_layer<8008, SUBNET>; template using btag16 = add_tag_layer<8016, SUBNET>; template using bskip8 = add_skip_layer; template using bskip16 = add_skip_layer; // neck tags template using ntag8 = add_tag_layer<6008, SUBNET>; template using ntag16 = add_tag_layer<6016, SUBNET>; template using ntag32 = add_tag_layer<6032, SUBNET>; template using nskip8 = add_skip_layer; template using nskip16 = add_skip_layer; template using nskip32 = add_skip_layer; // head tags template using htag8 = add_tag_layer<7008, SUBNET>; template using htag16 = add_tag_layer<7016, SUBNET>; template using htag32 = add_tag_layer<7032, SUBNET>; template using hskip8 = add_skip_layer; template using hskip16 = add_skip_layer; // yolo tags template using ytag8 = add_tag_layer<4008, SUBNET>; template using ytag16 = add_tag_layer<4016, SUBNET>; template using ytag32 = add_tag_layer<4032, SUBNET>; template