// The contents of this file are in the public domain. See LICENSE_FOR_EXAMPLE_PROGRAMS.txt /* Semantic segmentation using the PASCAL VOC2012 dataset. In segmentation, the task is to assign each pixel of an input image a label - for example, 'dog'. Then, the idea is that neighboring pixels having the same label can be connected together to form a larger region, representing a complete (or partially occluded) dog. So technically, segmentation can be viewed as classification of individual pixels (using the relevant context in the input images), however the goal usually is to identify meaningful regions that represent complete entities of interest (such as dogs). Instructions how to run the example: 1. Download the PASCAL VOC2012 data, and untar it somewhere. http://host.robots.ox.ac.uk/pascal/VOC/voc2012/VOCtrainval_11-May-2012.tar 2. Build the dnn_semantic_segmentation_train_ex example program. 3. Run: ./dnn_semantic_segmentation_train_ex /path/to/VOC2012 4. Wait while the network is being trained. 5. Build the dnn_semantic_segmentation_ex example program. 6. Run: ./dnn_semantic_segmentation_ex /path/to/VOC2012-or-other-images An alternative to steps 2-4 above is to download a pre-trained network from here: http://dlib.net/files/semantic_segmentation_voc2012net_v2.dnn It would be a good idea to become familiar with dlib's DNN tooling before reading this example. So you should read dnn_introduction_ex.cpp and dnn_introduction2_ex.cpp before reading this example program. */ #ifndef DLIB_DNn_SEMANTIC_SEGMENTATION_EX_H_ #define DLIB_DNn_SEMANTIC_SEGMENTATION_EX_H_ #include #include "pascal_voc_2012.h" // ---------------------------------------------------------------------------------------- // Introduce the building blocks used to define the segmentation network. // The network first does residual downsampling (similar to the dnn_imagenet_(train_)ex // example program), and then residual upsampling. In addition, U-Net style skip // connections are used, so that not every simple detail needs to represented on the low // levels. (See Ronneberger et al. (2015), U-Net: Convolutional Networks for Biomedical // Image Segmentation, https://arxiv.org/pdf/1505.04597.pdf) template class BN, int stride, typename SUBNET> using block = BN>>>>; template class BN, int stride, typename SUBNET> using blockt = BN>>>>; template