{'fraction_non_alphanumeric': 0.02582104320784055, 'fraction_numerical': 0.00669085426188569, 'mean_word_length': 4.647684938797233, 'pattern_counts': {'":': 0, '<': 1, '<?xml version=': 0, '>': 1, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Complex Relations in a Deep Structured Prediction Model for Fine Image Segmentation

Many deep learning architectures for semantic segmentation involve a Fully Convolutional Neural Network (FCN) followed by a Conditional Random Field (CRF) to carry out inference over an image. These models typically involve unary potentials based on local appearance features computed by FCNs, and binary potentials based on the displacement between pixels. We show that while current methods succeed in segmenting whole objects, they perform poorly in situations involving a large number of object parts. We therefore suggest incorporating into the inference algorithm additional higher-order potentials inspired by the way humans identify and localize parts. We incorporate two relations that were shown to be useful to human object identification - containment and attachment - into the energy term of the CRF and evaluate their performance on the Pascal VOC Parts dataset. Our experimental results show that the segmentation of fine parts is positively affected by the addition of these two relations, and that the segmentation of fine parts can be further influenced by complex structural features.


Introduction
Semantic segmentation is an important task in computer vision that comprises a subset of structured prediction methods. In recent years it has garnered much attention due to its use in street scene understanding for autonomous vehicles, medical image analysis, and a host of other applications for computer vision. The use of deep convolutional neural networks has resulted in substantial improvements for object-level segmentation. When used in conjunction with undirected graphical models, most commonly conditional random fields (CRFs), performance increases [5]. However, an overview of these results shows that there is considerable room for improvement, particularly for segmentation at the parts-level. The detailed, or fine segmentation of parts at the richness and accuracy of human-level can be crucial for visual tasks involving the understanding of actions and interactions [3,4].
Fine part segmentation remains a hard problem because most objects contain a large number of parts that may be arranged in many different configurations, and small parts often appear with low visibility. One fundamental issue with most current part segmentation methods is that boundary localization is poor. This results in segmentations filled with errors a human would never make, such as segmenting a horse's torso into disjoint parts or making its head disproportionately large. While CRFs based on unary and binary potentials were introduced with boundary refinement in mind, they do not capture the complex relations that humans use to identify object parts.
We propose incorporating potentials that express these relations directly into the structure of the CRF, specifically, containment and attachment, two complex relations that were shown to be useful to human identification of object parts [3]. The main challenge in adding these higher-order potentials to the CRF is carrying out inference over the altered structure. We use mean field variational inference to determine the most likely label for each pixel in an image, and derive update equations due to our potentials. An outline of our paper follows: in section 2 we discuss related work in the field of semantic segmentation. In section 3 we outline our complex potentials and present their update equations. In section 4 we present our results on the Pascal-Parts dataset [6] and conclude in section 5 with a discussion.

Related work
Significant progress has been made on semantic segmentation through the introduction of end-to-end Convolutional Neural Networks e.g., [5,14,17], by taking a network architecture that was originally designed for the ImageNet object classification task and adapting it to a 'Fully Convolutional Network' (FCN) in which the output map is equal in size and shape to the input layer. Similar to classification CNNs, FCNs incorporate pooling and convolutional layers, which cause resolution of the original visual signal to be gradually decreased with the depth of the network during the encoding stage. Then, up-sampling techniques and skip connections are used to recover the resolution of the input map during a decoding stage. As a result, the accuracy of boundary localization is limited, particularly when the segmented object or part appears with low resolution in the input image.
Much of the recent research on semantic segmentation has focused on the decoding stage: increasing the boundary accuracy while also providing a correct and coherent labeling of the objects or parts. The results of this research include sophisticated decoding architectures for encoder-decoder segmentation networks. For example, SegNet [2] stores indices of max-pooling layers in the encoding stage, and uses them later for "unpooling" layers in decoding. UNet [16] concatenates feature maps in encoding stage to upsampled feature maps in decoding stage, and RefineNet [12] which employs long-range residual connections for identity mapping, to pass high-resolution features from earlier convolutions to deeper layers. Even so, progress on semantic segmentation of objects and parts is slow; one reason for this might be that current systems do not take into account what is known about human identification and interpretation of object and parts.
A successful approach to address resolution limitations in semantic segmentation is to combine FCNs with an additional graphical model inference stage, most commonly a fully connected CRF in which each image pixel is a node, and every pair of nodes is connected, termed a dense CRF [11]. The energy equation for the CRF is typically based on the Gibbs energy of an Ising model and contains unary and binary potentials.
While the most successful approach for semantic segmentation to date is based on an FCN + CRF with powerful unary potentials provided by the FCN [5], recent work has shown that adding potentials that depend on more than two pixels, termed higher-order potentials, is useful for the general segmentation task (e.g., [1,9,13]). [9] extend the class of models on which efficient approximate inference may be performed over CRFs to the P n Potts model, and [1] build off of this pattern-based potential formulation by including a coherence term based on superpixels as a layer within the FCN rather than within the dense CRF inference module, and show improved performance for semantic segmentation.
While the terms in the extended energy equation combine intuitive notions of coherency between local regions of an image, they do not encompass more complex semantic relations between object parts that humans use to identify objects. Motivated by the role of complex relations in cognitive models for object image interpretation [3], and by the success of recent semantic segmentation algorithms to leverage performance via additional higher order potentials, we turn to study new complex relation terms in an FCN followed by the dense CRF framework for semantic part segmentation. As will be shown below, the contribution of such relation terms, which are inspired by cognitive models, is significant to part segmentation performance, particularly when the number of parts is high.

Adding more complex relations
We are focusing here on two relation terms, the containment of parts and the attachment of parts, which were shown to be useful for replicating human object interpretation [3], and a derivation of their mean field update rule. We then use the derived rules for implementing a dense CRF model (Sec. 4) that includes the basic unary and binary potentials, with the addition of the novel, more complex potential terms derived here. Note that higher-order potential terms, beyond the ones discussed here, could be also considered for improving semantic part segmentation. We begin by introducing notation to describe the dense CRF and our potentials. Our goal is to find an optimal labeling for the set of latent variables X = {x 1 , x 2 , ..., x N } where each x i is a node in our CRF representing a pixel in an image. Each variable takes on a label in the set L = {1, 2, 3, ..., L}, and P (X) denotes the true distribution of label assignments to pixels for a single image.
Exact inference on X is intractable, so we use mean field variational inference to find a distribution Q(X) that is a good approximation to the true, or target distribution, P (X). In the following derivation we assume that Q(X) satisfies the mean field approximation, i.e., The energy of the basic dense CRF is where the first term is the unary potential and is measured over each pixel, and the second term is taken over every pair of pixels [11].
Using the KL-divergence to measure the distance between Q(X) and P (X) leads to the following update equation for each distribution Q i (x i ) that depends on the potentials in the energy [10]: where the partition function pression. The first sum is taken over all potential functions ψ for which pixel x i is in the domain U ψ of the function. The second sum is taken over all cliques c ∈ C, the total set of cliques in the CRF, where a clique is a complete subgraph of the CRF. The third sum is taken over x c , the set of all configurations of pixels in the clique when x i = l. In the body of the expression we sum over Q c−i (x c−i ), the joint distribution over the variables {x j ∈ c : j = i} when x i = l, multiplied by the value ψ c (x c ) of the potential applied to clique c.
To increase coherency within local image regions and promote boundary localization, a superpixel potential was added to Eq. 1 by [1], namely: where each clique c is a set of pixels in a superpixel, and the term enforces that a low weight is added to the energy when all pixels in a clique take on the same label. Our terms build off of this pattern-based potential by changing the condition for adding a low weight. The corresponding update rule for this potential is

Containment
We consider the containment potential in which we assign a low weight w low (l) to the clique c when, for all variables In all other cases we assign a high weight w high . Note that w low depends on the label l of the pixel we are updating over, as well as some label l that we determine prior to inference and which depends on the clique. In our formulation for segmentation, each clique c is the boundary of a superpixel, and l is the most common label within that superpixel. At runtime the value for w low may be determined from a look-up table as described below.
As an example, say we are considering the boundary of a superpixel whose most common label l is "left eye". As we update the value of each pixel in the boundary we will consider all possible labels l for each pixel. If l is "left eye" or "head" then w low (l) ≈ 0; however if l is any other label such as "torso" then w low (l) = w high , since intuitively we don't want to enforce any containment relation between the eyes and other labels. These relationships between labels are determined beforehand or learned and then stored in a look-up table. Learning a relation involves measuring its presence in the dataset. Once a relation potential is well-defined, it is straightforward to measure its presence between every pair of labels by calculating the potential directly for each image in the ground truth training set. Once a proportion of images containing the relation has been formed for each pair of labels, a threshold may be set, above which it is determined that a relation between the pair of labels exists. Then these relations may be used during inference. Figure 1 demonstrates exactly which pixels in a superpixel would be included in a containment clique.
Plugging ψ i/o into Eq. 2 gives the following update for each clique c: Consider the first term on the right hand side of the above. This term encompasses situations in which x i = OR(l, l ) for all x i ∈ c, in which case we know the likelihood of this happening can be calculated as The second term encompasses all other configurations of the pixels in the clique, so this may be calculated as the complement of the above: Note that in the products above we satisfy the constraint that j = i because we know that x i = l. The final update expression for the containment potential is then

Attachment
Our approach to forming a potential that measures the presence of attachment between parts requires more care. We first consider the problem of what cliques the attachment potential ψ a will be measured over. Attachment is measured across boundaries, and yet finding the boundaries of objects is precisely the obstacle we are trying to overcome. In keeping with our superpixel formulation we consider pairs of superpixels, and estimate the distance between them by calculating the euclidean distance between areas labeled head, the yellow is labeled eye, and we see that the eye is over-segmented. Each x marks a pixel along the boundary, which together constitute a clique that containment is calculated over. Right: The corrected labeling.
their centroids. If this distance falls below a certain threshold d, then we know that the superpixels are neighbors in a loose sense. Information on how the threshold is set may be found in the appendix 6.
Thus, to determine the cliques for the attachment term we use the following algorithm: For notational simplicity, let c 1 = sp 1 and c 2 = sp 2 so that c =< c 1 , c 2 >. We define the attachment potential over each pair c as ψ a (x c ) = w low (l 1 , l 2 ), ∀j ∈ c 1 , x c1 = l 1 , ∀k ∈ c 1 , x c2 = l 2 w high , otherwise (7) where l 1 and l 2 are the most frequent labels in the sets x c1 and x c2 , respectively. In cases where l 1 = most frequent label(c 1 ) or l 2 = most frequent label(c 2 ), w low (l 1 , l 2 ) = w high . Note that the condition for assigning a low weight is strict in the sense that we do not allow any label sharing between the two superpixels within the clique. Figure 2 illustrates how centroids are key to the formation of an attachment clique.
To compute the mean field update for the attachment term, we again begin with the update rule in Eq. 2 and consider the update at pixel x i for label l. For what distributions of Q would we assign a low weight? If i ∈ c 1 then applying the mean field assumption gives the joint distribution over the pixels in x c to be . Likewise, if i ∈ c 2 and we assign a low weight We introduce an indicator function 1 l∈{l1,l2} to denote whether the label l that we are updating over is equal to either l 1 or l 2 . Putting the two expressions together gives the following distribution for assigning a low weight Let expression 8 be denoted by γ. In all other cases we assign a high weight, so we subtract γ from the sum of the joint distribution of labels over clique c: 1 − γ. This leads to the following update for each pixel.

Experimental results
To test and evaluate the new potential terms, we implemented a dense CRF model in which the energy function contains the terms in Eq. 1, with the addition of the superpixel potential in 3, the containment potential in Eq. 5 and the attachment potential in Eq. 7, namely: Our inference algorithm for the dense CRF model was based on the mean field algorithm, including the update rules derived for the superpixel potential Eq. 3 in [1] and the update rules for Eq. 5 and Eq. 7 as derived in Sec. 3.1 and Sec. 3.2 respectively.
For the unary potentials we used the output from the DeepLab convolutional network [5], which is based on ResNet101 [8]. Our potential terms were added to the dense CRF open source implementation packaged with the DeepLab implementation, and the mean field inference algorithm was updated accordingly. For each of the three potential terms we added to the energy function we assigned weights w high and w low that were learned in a grid search manner over a validation set.
Our tests were focused on semantic segmentation of parts, as well as tests on semantic segmentation of objects for control. For part segmentation, we used the VOC part segmentation benchmark [6], including evaluations on both coarse and fine set of parts. In the fine part segmentation the object is segmented into multiple parts. There are at most 21 for the horse category and 24 for the person category, including fine parts such as eye, ear, nose, etc. In the coarse part segmentation the small parts are merged, and the number of total parts is much lower (5 for the horse and 6 for person).
Our assumption is that when there are a higher number of parts, the containment and attachment potentials are more effective. For object segmentation we used the PASCAL VOC object segmentation benchmark [7]. While there are other datasets available for part segmentation [15], we found Pascal Parts to have more examples than the other part datasets.
Our tests on the part segmentation task included the horse category and the person category, since there are more available fine ground truth annotations in these categories than in others. For the horse category, we used the 325 images for training and performed 4-fold validation, with 100 images for testing. For the person category we used 1985 images for training with 4-fold validation and 1515 for testing. We compared our segmentation results on the test set with several state-of-the-art part segmentation algorithms, namely the DeepLab system based on ResNet101 [5], HZAN [18], and RefineNet [12]. Both HAZN and RefineNet use higher-order potentials in a dense CRF framework.    Fig. 3.
An evaluation of our model shows that the contribution of the attachment and containment potential terms is higher for the fine part segmentation task, where we achieve better results with the attachment term and comparable to the state-of-the-art results with the containment term. In the coarse part segmentation and object segmentation tasks, our model is comparable with the best current models, such as Deeplab ResNet101 [5]. These results highlight the role of more complex high-order relations in structured prediction models for part segmentation, where the number of object parts is large.

Discussion
In this paper we studied structural prediction models, which follow an FCN stage for the fine semantic segmentation of object parts. Our study focused on the dense CRF graphical model, which is currently the dominant graphical model coupled with FCNs for semantic segmentation. Dense CRFs are often used together with deep convolutional networks to achieve accurate detection of boundaries, and are integrated either as a separate stage after the CNNs or integrated in an end-to-end fashion. To solve the inference problem in an undirected graphical model, we have used the mean field approach, which is commonly taken in dense CRF models for segmentation.
Our study included the evaluation of binary and higher-order potential terms in the CRF that are more complex than previously used for semantic segmentation. Our motivation to study such terms is derived from studies of human-like detection and localization of parts in object images. In particular we derived CRF formulations for two prominent relations from human studies, namely containment and attachment of parts. Our results show that when the segmentation task involves the localization of multiple fine-level parts, the contribution of relational features such as containment or attachment increases. This motivates further work on complex relations in a dense CRF to study the segmentation of fine parts, aimed towards replicating the richness and accuracy of human-level part segmentation. Fine part segmentation could be an avenue for solving difficult visual tasks, such as understanding object-agent and agent-agent interactions.
A major effort in semantic segmentation research is focused on different architectures for the decoding stage in Fully Convolutional Networks. The decoding stage usually includes mechanisms such as deconvolutions, unpooling, skip connections, pyramid pooling, gating, etc. Our work suggests that the decoding architecture in semantic segmentation networks should have the capacity to learn complex relations between pixels and superpixels, such as containment, attachment, and others. Here we proposed an implementation based on undirected graphical models, but it would be interesting to further explore network architectures to compute such relations in FCN fashion. Such architectures may include lateral (recurrent) or feedback connections, to compute the complex (and computationally expensive) relations selectively, given some prior. First steps in this direction were shown by [19] for dense CRFs with the basic relations in Eq. 1, which were integrated in end-to-end deep Recurrent Neural Networks.
6 Appendix: Determining threshold d The threshold d by which we measure that two superpixels may satisfy attachment can be determined from the average size of the superpixels. In generating the superpixels we have imposed a regularity constraint so that each superpixel is connected and in general they have a similar shape. The threshold d can then be set to the average width of each superpixel.