From c21c3b0befeb46a51b6bf3758ffa30813bea0ff0 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 9 Mar 2024 14:19:22 +0100 Subject: Adding upstream version 1.44.3. Signed-off-by: Daniel Baumann --- ml/dlib/examples/dnn_imagenet_ex.cpp | 171 +++++++++++++++++++++++++++++++++++ 1 file changed, 171 insertions(+) create mode 100644 ml/dlib/examples/dnn_imagenet_ex.cpp (limited to 'ml/dlib/examples/dnn_imagenet_ex.cpp') diff --git a/ml/dlib/examples/dnn_imagenet_ex.cpp b/ml/dlib/examples/dnn_imagenet_ex.cpp new file mode 100644 index 000000000..d1fa82823 --- /dev/null +++ b/ml/dlib/examples/dnn_imagenet_ex.cpp @@ -0,0 +1,171 @@ +// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt +/* + This example shows how to classify an image into one of the 1000 imagenet + categories using the deep learning tools from the dlib C++ Library. We will + use the pretrained ResNet34 model available on the dlib website. + + The ResNet34 architecture is from the paper Deep Residual Learning for Image + Recognition by He, Zhang, Ren, and Sun. The model file that comes with dlib + was trained using the dnn_imagenet_train_ex.cpp program on a Titan X for + about 2 weeks. This pretrained model has a top5 error of 7.572% on the 2012 + imagenet validation dataset. + + For an introduction to dlib's DNN module read the dnn_introduction_ex.cpp and + dnn_introduction2_ex.cpp example programs. + + + Finally, these tools will use CUDA and cuDNN to drastically accelerate + network training and testing. CMake should automatically find them if they + are installed and configure things appropriately. If not, the program will + still run but will be much slower to execute. +*/ + + + +#include +#include +#include +#include +#include + +using namespace std; +using namespace dlib; + +// ---------------------------------------------------------------------------------------- + +// This block of statements defines the resnet-34 network + +template