Semantic Image Segmentation via Deep Parsing Network
Ziwei Liu, Xiaoxiao Li, Ping Luo, Chen Change Loy, Xiaoou Tang
Introduction
Markov Random Field (MRF) or Conditional Random Field (CRF) has achieved great successes in semantic image segmentation, which is one of the most challenging problems in computer vision. Existing works such as can be generally categorized into two groups based on their definitions of the unary and pairwise terms of MRF.
In the first group, researchers improved labeling accuracy by exploring rich information to define the pairwise functions, including long-range dependencies , high-order potentials , and semantic label contexts . For example, Krähenbühl et al. attained accurate segmentation boundary by inferring on a fully-connected graph. Vineet et al. extended by defining both high-order and long-range terms between pixels. Global or local semantic contexts between labels were also investigated by . Although they accomplished promising results, they modeled the unary terms as SVM or Adaboost, whose learning capacity becomes a bottleneck. The learning and inference of complex pairwise terms are often expensive.
In the second group, people learned a strong unary classifier by leveraging the recent advances of deep learning, such as the Convolutional Neural Network (CNN). With deep models, these works demonstrated encouraging results using simple definition of the pairwise function or even ignore it. For instance, Long et al. transformed fully-connected layers of CNN into convolutional layers, making accurate per-pixel classification possible using the contemporary CNN architectures that were pre-trained on ImageNet . Chen et al. improved by feeding the outputs of CNN into a MRF with simple pairwise potentials, but it treated CNN and MRF as separated components. A recent advance was obtained by , which jointly trained CNN and MRF by passing the error of MRF inference backward into CNN, but iterative inference of MRF such as the mean field algorithm (MF) is required for each training image during back-propagation (BP). Zheng et al. further showed that the procedure of MF inference can be represented as a Recurrent Neural Network (RNN), but their computational costs are similar. We found that directly combing CNN and MRF as above is inefficient, because CNN typically has millions of parameters while MRF infers thousands of latent variables; and even worse, incorporating complex pairwise terms into MRF becomes impractical, limiting the performance of the entire system.
This work proposes a novel Deep Parsing Network (DPN), which is able to jointly train CNN and complex pairwise terms. DPN has several appealing properties. (1) DPN solves MRF with a single feed-forward pass, reducing computational cost and meanwhile maintaining high performance. Specifically, DPN models unary terms by extending the VGG-16 network (VGG16) pre-trained on ImageNet, while additional layers are carefully designed to model complex pairwise terms. Learning of these terms is transformed into deterministic end-to-end computation by BP, instead of embedding MF into BP as did. Although MF can be represented by RNN , it needs to recurrently compute the forward pass so as to achieve good performance and thus is time-consuming, e.g. each forward pass contains hundred thousands of weights. DPN approximates MF by using only one iteration. This is made possible by joint learning strong unary terms and rich pairwise information. (2) Pairwise terms determine the graphical structure. In previous works, if the former is changed, so is the latter as well as its inference procedure. But with DPN, modifying the complexity of pairwise terms, e.g. range of pixels and contexts, is as simple as modifying the receptive fields of convolutions, without varying BP. DPN is able to represent multiple types of pairwise terms, making many previous works as its special cases. (3) DPN approximates MF with convolutional and pooling operations, which can be speeded up by low-rank approximation and easily parallelized in a Graphical Processing Unit (GPU).
Our contributions are summarized as below. (1) A novel DPN is proposed to jointly train VGG16 and rich pairwise information, i.e. mixture of label contexts and high-order relations. Compared to existing deep models, DPN can approximate MF with only one iteration, reducing computational cost but still maintaining high performance. (2) We disclose that DPN represents multiple types of MRFs, making many previous works such as RNN and DeepLab as its special cases. (3) Extensive experiments investigate which component of DPN is crucial to achieve high performance. A single DPN model achieves a new state-of-the-art accuracy of 77.5% on the PASCAL VOC 2012 test set. (4) We analyze the time complexity of DPN on GPU.
Our Approach
DPN learns MRF by extending VGG16 to model unary terms and additional layers are carefully designed for pairwise terms.
Overview MRF is an undirected graph where each node represents a pixel in an image , and each edge represents relation between pixels. Each node is associated with a binary latent variable, , indicating whether a pixel has label . We have , representing a set of labels. The energy function of MRF is written as
where , , and denote a set of latent variables, nodes, and edges, respectively. is the unary term, measuring the cost of assigning label to the -th pixel. For instance, if pixel belongs to the first category other than the second one, we should have . Moreover, is the pairwise term that measures the penalty of assigning labels to pixels respectively.
Intuitively, the unary terms represent per-pixel classifications, while the pairwise terms represent a set of smoothness constraints. The unary term in Eqn.(1) is typically defined as
where indicates the probability of the presence of label at pixel , modeling by VGG16. To simplify discussions, we abbreviate it as . The smoothness term can be formulated as
However, Eqn.(3) has two main drawbacks. First, its first term captures the co-occurrence frequency of two labels in the training data, but neglects the spatial context between objects. For example, ‘person’ may appear beside ‘table’, but not at its bottom. This spatial context is a mixture of patterns, as different object configurations may appear in different images. Second, it defines only the pairwise relations between pixels, missing their high-order interactions.
To resolve these issues, we define the smoothness term by leveraging rich information between pixels, which is one of the advantages of DPN over existing deep models. We have
The first term in Eqn.(4) learns a mixture of local label contexts, penalizing label assignment in a local region, where is the number of components in mixture and is an indicator, determining which component is activated. We define and . An intuitive illustration is given in Fig.1 (b), where the dots in red and blue represent a center pixel and its neighboring pixels , i.e. , and indicates assigning label to pixel . Here, outputs labeling cost between and with respect to their relative positions. For instance, if represent ‘person’ and ‘table’, the learned penalties of positions that are at the bottom of center should be large. The second term basically models a triple penalty, which involves pixels , , and ’s neighbors, implying that if and are compatible, then should be also compatible with ’s nearby pixels , , as shown in Fig.1 (a).
Learning parameters (i.e. weights of VGG16 and costs of label contexts) in Eqn.(1) is to minimize the distances between ground-truth label map and , which needs to be inferred subject to the smoothness constraints.
Inference Overview Inference of Eqn.(1) can be obtained by the mean field (MF) algorithm , which estimates the joint distribution of MRF, , by using a fully-factorized proposal distribution, , where each is a variable we need to estimate, indicating the predicted probability of assigning label to pixel . To simplify the discussion, we denote and as and , respectively. is typically optimized by minimizing a free energy function of MRF,
Specifically, the first term in Eqn.(5) characterizes the cost of each pixel’s predictions, while the second term characterizes the consistencies of predictions between pixels. The last term is the entropy, measuring the confidences of predictions. To estimate , we differentiate Eqn.(5) with respect to it and equate the resulting expression to zero. We then have a closed-form expression,
such that the predictions for each pixel is independently attained by repeating Eqn.(6), which implies whether pixel have label is proportional to the estimated probabilities of all its neighboring pixels, weighted by their corresponding smoothness penalties. Substituting Eqn.(4) into (6), we have
where each is initialized by the corresponding in Eqn.(2), which is the unary prediction of VGG16. Eqn.(2) satisfies the smoothness constraints.
Deep Parsing Network
This section describes the implementation of Eq.(2) in a Deep Parsing Network (DPN). DPN extends VGG16 as unary term and additional layers are designed to approximate one iteration of MF inference as the pairwise term. The hyper-parameters of VGG16 and DPN are compared in Table 1.
VGG16 As listed in Table 1 (a), the first row represents the name of layer and ‘-’ in the second row represents the size of the receptive field and the stride of convolution, respectively. For instance, ‘3-1’ in the convolutional layer implies that the receptive field of each filter is 33 and it is applied on every single pixel of an input feature map, while ‘2-2’ in the max-pooling layer indicates each feature map is pooled over every other pixel within a 22 local region. The last three rows show the number of the output feature maps, activation functions, and the size of output feature maps, respectively. As summarized in Table 1 (a), VGG16 contains thirteen convolutional layers, five max-pooling layers, and three fully-connected layers. These layers can be partitioned into twelve groups, each of which covers one or more homogenous layers. For example, the first group comprises two convolutional layers with 33 receptive field and 64 output feature maps, each of which is 224224.
To make full use of VGG16, which is pre-trained by ImageNet, we adopt all its parameters to initialize the filters of the first ten groups of DPN. To simplify the discussions, we take PASCAL VOC 2012 (VOC12) as an example. Note that DPN can be easily adapted to any other semantic image segmentation dataset by modifying its hyper-parameters. VOC12 contains 21 categories and each image is rescaled to 512512 in training. Therefore, DPN needs to predict totally 51251221 labels, i.e. one label for each pixel. To this end, we extends VGG16 in two aspects.
In particular, let a and b denote the -th group in Table 1 (a) and (b), respectively. First, we increase resolution of VGG16 by removing its max pooling layers at a8 and a10, because most of the information is lost after pooling, e.g. a10 reduces the input size by 32 times, i.e. from 224224 to 77. As a result, the smallest size of feature map in DPN is 6464, keeping much more information compared with VGG16. Note that the filters of b8 are initialized as the filters of a9, but the 33 receptive field is padded into 55 as shown in Fig.2 (a), where the cells in white are the original values of the a9’s filter and the cells in gray are zeros. This is done because a8 is not presented in DPN, such that each filter in a9 should be convolved on every other pixel of a7. To maintain the convolution with one stride, we pad the filters with zeros. Furthermore, the feature maps in b11 are up-sampled to 512512 by bilinear interpolation. Since DPN is trained with label maps of the entire images, the missing information in the preceding layers of b11 can be recovered by BP.
Second, two fully-connected layers at a11 are transformed to two convolutional layers at b9 and b10, respectively. As shown in Table 1 (a), the first ‘fc’ layer learns 775124096 parameters, which can be altered to 4096 filters in b9, each of which is 2525512. Since a8 and a10 have been removed, the 77 receptive field is padded into 2525 similar as above and shown in Fig.2 (b). The second ‘fc’ layer learns a 40964096 weight matrix, corresponding to 4096 filters in b10. Each filter is 114096.
Overall, b11 generates the unary labeling results, producing twenty-one 512512 feature maps, each of which represents the probabilistic label map of each category.
2 Modeling Smoothness Terms
The last four layers of DPN, i.e. from b12 to b15, are carefully designed to smooth the unary labeling results.
b12 As listed in Table 1 (b), ‘lconv’ in b12 indicates a locally convolutional layer, which is widely used in face recognition to capture different information from different facial positions. Similarly, distinct spatial positions of b12 have different filters, and each filter is shared across 21 input channels, as shown in Fig.2 (c). It can be formulated as
b13 As shown in Table 1 (b) and Fig.3 (a), b13 is a convolutional layer that generates 105 feature maps by using 105 filters of size 9921. For example, the value of is attained by applying a 9921 filter at positions . In other words, b13 learns a filter for each category to penalize the probabilistic label maps of b12, corresponding to the local label contexts in Eqn.(2) by assuming and , as shown in Fig.1 (d).
b14 As illustrated in Table 1 and Fig.3 (b), b14 is a block min pooling layer that pools over every 11 region with one stride across every 5 input channels, leading to 21 output channels, i.e. 105521. b14 activates the contextual pattern with the smallest penalty.
b15 This layer combines both the unary and smoothness terms by summing the outputs of b11 and b14 in an element-wise manner similar to Eqn.(2),
where probability of assigning label to pixel is normalized over all the labels.
Relation to Previous Deep Models Many existing deep models such as employed Eqn.(3) as the pairwise terms, which are the special cases of Eqn.(2). To see this, let 1 and , the right hand side of (2) reduces to
3 Learning Algorithms
Learning The first ten groups of DPN are initialized by VGG16We use the released VGG16 model, which is public available at http://www.robots.ox.ac.uk/~vgg/research/very_deep/, while the last four groups can be initialized randomly. DPN is then fine-tuned in an incremental manner with four stages. During fine-tuning, all these stages solve the pixelwise softmax loss , but updating different sets of parameters.
First, we add a loss function to b11 and fine-tune the weights from b1 to b11 without the last four groups, in order to learn the unary terms. Second, to learn the triple relations, we stack b12 on top of b11 and update its parameters (i.e. in the distance measure), but the weights of the preceding groups (i.e. b1b11) are fixed. Third, b13 and b14 are stacked onto b12 and similarly, their weights are updated with all the preceding parameters fixed, so as to learn the local label contexts. Finally, all the parameters are jointly fine-tuned.
Implementation DPN transforms Eqn.(2) into convolutions and poolings in the groups from b12 to b15, such that filtering at each pixel can be performed in a parallel manner. Assume we have input and output feature maps, pixels, filters with receptive field, and a mini-batch with samples. b12 takes a total operations, b13 takes operations, while both b14 and b15 require operations. For example, when 10 as in our experiment, we have 215122502101.31011 operations in b12, which has the highest complexity in DPN. We parallelize these operations using matrix multiplication on GPU as did, b12 can be computed within 30ms. The total runtime of the last four layers of DPN is 75ms. Note that convolutions in DPN can be further speeded up by low-rank decompositions of the filters and model compressions .
However, direct calculation of Eqn.(2) is accelerated by fast Gaussian filtering . For a mini-batch of ten 512512 images, a recently optimized implementation takes 12 seconds on CPU to compute one iteration of (2). Therefore, DPN makes (2) easier to be parallelized and speeded up.
Experiments
Dataset We evaluate the proposed approach on the PASCAL VOC 2012 (VOC12) dataset, which contains 20 object categories and one background category. Following previous works such as , we employ images for training, images for validation, and images for testing.
Evaluation Metrics All existing works employed mean pixelwise intersection-over-union (denoted as mIoU) to evaluate their performance. To fully examine the effectiveness of DPN, we introduce another three metrics, including tagging accuracy (TA), localization accuracy (LA), and boundary accuracy (BA). (1) TA compares the predicted image-level tags with the ground truth tags, calculating the accuracy of multi-class image classification. (2) LA evaluates the IoU between the predicted object bounding boxesThey are the bounding boxes of the predicted segmentation regions. and the ground truth bounding boxes (denoted as bIoU), measuring the precision of object localization. (3) For those objects that have been correctly localized, we compare the predicted object boundary with the ground truth boundary, measuring the precision of semantic boundary similar to .
Comparisons DPN is compared with the best-performing methods on VOC12, including FCN , Zoom-out , DeepLab , WSSL , BoxSup , Piecewise , and RNN . All these methods are based on CNNs and MRFs, and trained on VOC12 data following . They can be grouped according to different aspects: (1) joint-train: Piecewise and RNN; (2) w/o joint-train: DeepLab, WSSL, FCN, and BoxSup; (3) pre-train on COCO: RNN, WSSL, and BoxSup. The first and the second groups are the methods with and without joint training CNNs and MRFs, respectively. Methods in the last group also employed MS-COCO to pre-train deep models. To conduct a comprehensive comparison, the performance of DPN are reported on both settings, i.e., with and without pre-training on COCO.
In the following, Sec.4.1 investigates the effectiveness of different components of DPN on the VOC12 validation set. Sec.4.2 compares DPN with the state-of-the-art methods on the VOC12 test set.
All the models evaluated in this section are trained and tested on VOC12.
Triple Penalty The receptive field of b12 indicates the range of triple relations for each pixel. We examine different settings of the receptive fields, including ‘1010’, ‘5050’, and ‘100100’, as shown in Table 2 (a), where ‘5050’ achieves the best mIoU, which is sightly better than ‘100100’. For a 512512 image, this result implies that 5050 neighborhood is sufficient to capture relations between pixels, while smaller or larger regions tend to under-fit or over-fit the training data. Moreover, all models of triple relations outperform the ‘baseline’ method that models dense pairwise relations, i.e. VGG16+denseCRF .
Label Contexts Receptive field of b13 indicates the range of local label context. To evaluate its effectiveness, we fix the receptive field of b12 as 5050. As summarized in Table 2 (b), ‘99 mixtures’ improves preceding settings by 1.7, 0.5, and 0.2 percent respectively. We observe large gaps exist between ‘11’ and ‘55’. Note that the 11 receptive field of b13 corresponds to learning a global label co-occurrence without considering local spatial contexts. Table 2 (c) shows that the pairwise terms of DPN are more effective than DSN and DeepLabThe other deep models such as RNN and Piecewise did not report the exact imrprovements after combining unary and pairwise terms..
More importantly, mIoU of all the categories can be improved when increasing the size of receptive field and learning a mixture. Specifically, for each category, the improvements of the last three settings in Table 2 (b) over the first one are 1.20.2, 1.50.2, and 1.70.3, respectively.
We also visualize the learned label compatibilities and contexts in Fig.4 (a) and (b), respectively. (a) is obtained by summing each filter in b13 over 99 region, indicating how likely a column object would present when a row object is presented. Blue represents high possibility. (a) is non-symmetry. For example, when ‘horse’ is presented, ‘person’ is more likely to present than the other objects. Also, ‘chair’ is compatible with ‘table’ and ‘bkg’ is compatible with all the objects. (b) visualizes some contextual patterns, where ‘A:B’ indicates that when ‘A’ is presented, where ‘B’ is more likely to present. For example, ‘bkg’ is around ‘train’, ‘motor bike’ is below ‘person’, and ‘person’ is sitting on ‘chair’.
Incremental Learning As discussed in Sec.3.3, DPN is trained in an incremental manner. The right hand side of Table 3 (a) demonstrates that each stage leads to performance gain compared to its previous stage. For instance, ‘triple penalty’ improves ‘unary term’ by 2.3 percent, while ‘label contexts’ improves ‘triple penalty’ by 1.8 percent. More importantly, joint fine-tuning all the components (i.e. unary terms and pairwise terms) in DPN achieves another gain of 1.3 percent. A step-by-step visualization is provided in Fig.5.
We also compare ‘incremental learning’ with ‘joint learning’, which fine-tunes all the components of DPN at the same time. The training curves of them are plotted in Fig.6 (a), showing that the former leads to higher and more stable accuracies with respect to different iterations, while the latter may get stuck at local minima. This difference is easy to understand, because incremental learning only introduces new parameters until all existing parameters have been fine-tuned.
One-iteration MF DPN approximates one iteration of MF. Fig.6 (b) illustrates that DPN reaches a good accuracy with one MF iteration. A CRF with dense pairwise edges needs more than 5 iterations to converge. It also has a large gap compared to DPN. Note that the existing deep models such as required 510 iterations to converge as well.
Different Components Modeling Different Information We further evaluate DPN using three metrics. The results are given in Fig.7. For example, (a) illustrates that the tagging accuracy can be improved in the third stage, as it captures label co-occurrence with a mixture of contextual patterns. However, TA is decreased a little after the final stage. Since joint tuning maximizes segmentation accuracies by optimizing all components together, extremely small objects, which rarely occur in VOC training set, are discarded. As shown in (b), accuracies of object localization are significantly improved in the second and the final stages. This is intuitive because the unary prediction can be refined by long-range and high-order pixel relations, and joint training further improves results. (c) discloses that the second stage also captures object boundary, since it measures dissimilarities between pixels.
Per-class Analysis Table 3 (a) reports the per-class accuracies of four evaluation metrics, where the first four rows represent the mIoU of four stages, while the last three rows represent TA, LA, and BA, respectively. We have several valuable observations, which motivate future researches. (1) Joint training benefits most of the categories, except animals such as ‘bird’, ‘cat’, and ‘cow’. Some instances of these categories are extremely small so that joint training discards them for smoother results. (2) Training DPN with pixelwise label maps implicitly models image-level tags, since it achieves a high averaged TA of 96.4%. (3) Object localization always helps. However, for the object with complex boundary such as ‘bike’, its mIoU is low even it can be localized, e.g. ‘bike’ has high LA but low BA and mIoU. (4) Failures of different categories have different factors. With these three metrics, they can be easily identified. For example, the failures of ‘chair’, ‘table’, and ‘plant’ are caused by the difficulties to accurately capture their bounding boxes and boundaries. Although ‘bottle’ and ‘tv’ are also difficult to localize, they achieve moderate mIoU because of their regular shapes. In other words, mIoU of ‘bottle’ and ‘tv’ can be significantly improved if they can be accurately localized.
2 Overall Performance
As shown in Table 3 (b), we compare DPN with the best-performing methodsThe results of these methods were presented in either the published papers or arXiv pre-prints. on VOC12 test set based on two settings, i.e. with and without pre-training on COCO. The approaches pre-trained on COCO are marked with ‘’. We evaluate DPN on several scales of the images and then average the results following .
DPN outperforms all the existing methods that were trained on VOC12, but DPN needs only one MF iteration to solve MRF, other than 10 iterations of RNN, DeepLab, and Piecewise. By averaging the results of two DPNs, we achieve 74.1% accuracy on VOC12 without outside training data. As discussed in Sec.3.3, MF iteration is the most complex step even when it is implemented as convolutions. Therefore, DPN at least reduces 10 runtime compared to previous works.
Following , we pre-train DPN with COCO, where 20 object categories that are also presented in VOC12 are selected for training. A single DPN† has achieved 77.5% mIoU on VOC12 test set. As shown in Table 3 (b), we observe that DPN† achieves best performances on more than half of the object classes. Please refer to the appendices for visual quality comparisons.
Conclusion
We proposed Deep Parsing Network (DPN) to address semantic image segmentation, which has several appealing properties. First, DPN unifies the inference and learning of unary term and pairwise terms in a single convolutional network. No iterative inference are required during back-propagation. Second, high-order relations and mixtures of label contexts are incorporated to its pairwise terms modeling, making existing works serve as special cases. Third, DPN is built upon conventional operations of CNN, thus easy to be parallelized and speeded up.
DPN achieves state-of-the-art performance on VOC12, and multiple valuable facts about semantic image segmention are revealed through extensive experiments. Future directions include investigating the generalizability of DPN to more challenging scenarios, e.g. large number of object classes and substantial appearance/scale variations.
References
Appendix A Fast Implementation of Locally Convolution
b12 in DPN is a locally convolutional layer. As mentioned in Eqn.(3), the local filters in b12 are computed by the distances between RGB values of the pixels. XY coordinates are omitted here because they could be pre-computed. To accelerate the computation of locally convolution, lookup table-based filtering approach is employed. We first construct a lookup table storing distances between any two pixel intensities (ranging from 0 to 255), which results in a matrix. Then when we perform locally convolution, the kernels’ coefficients can be obtained efficiently by just looking up the table.
Appendix B Visual Quality Comparisons
In the following, we inspect visual quality of obtained label maps. Fig.8 demonstrates the comparisons of DPN with FCN and DeepLab . We use the publicly released modelhttp://dl.caffe.berkeleyvision.org/fcn-8s-pascal.caffemodel to re-generate label maps of FCN while the results of DeepLab are extracted from their published paper. DPN generally makes more accurate predictions in both image-level and instance-level.
We also include more examples of DPN label maps in Fig.9. We observe that learning local label contexts helps differentiate confusing objects and learning triple penalty facilitates the capturing of intrinsic object boundaries.