From a49a42d61a8ede8aa0167cba1d3e7b93e136c0ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adri=C3=A0=20Arrufat?= Date: Mon, 7 Jun 2021 01:00:56 +0900 Subject: [PATCH 01/62] Initial version of the loss_yolo layer, still not working --- dlib/dnn/loss.h | 482 +++++++++++++++++++++++++++++++++ examples/CMakeLists.txt | 1 + examples/dnn_yolo_train_ex.cpp | 256 +++++++++++++++++ 3 files changed, 739 insertions(+) create mode 100644 examples/dnn_yolo_train_ex.cpp diff --git a/dlib/dnn/loss.h b/dlib/dnn/loss.h index fff8445e42..682f44e1bb 100644 --- a/dlib/dnn/loss.h +++ b/dlib/dnn/loss.h @@ -3447,6 +3447,488 @@ namespace dlib // ---------------------------------------------------------------------------------------- + using yolo_rect = mmod_rect; + inline bool operator<(const yolo_rect& lhs, const yolo_rect& rhs) + { + return lhs.detection_confidence < rhs.detection_confidence; + } + + struct yolo_options + { + public: + struct anchor_box_details + { + anchor_box_details() = default; + anchor_box_details(unsigned long w, unsigned long h) : width(w), height(h) {} + + unsigned long width = 0; + unsigned long height = 0; + + friend inline void serialize(const anchor_box_details& item, std::ostream& out) + { + int version = 0; + serialize(version, out); + serialize(item.width, out); + serialize(item.height, out); + } + + friend inline void deserialize(anchor_box_details& item, std::istream& in) + { + int version = 0; + deserialize(version, in); + deserialize(item.width, in); + deserialize(item.height, in); + } + }; + + yolo_options() = default; + + template