Deep Neural Networks In Fully Connected CRF For Image Labeling With Social Network Metadata
Chengjiang Long Roddy Collins Eran Swears Anthony Hoogs
cs.CV







Deep Neural Networks In Fully Connected CRF For Image Labeling With Social Network Metadata
    Chengjiang Long        Roddy Collins        Eran Swears        Anthony Hoogs

Kitware Inc.

28 Corporate Drive, Clifton Park, NY 12065

{chengjiang.long, roddy.collins, eran.swears, anthony.hoogs}@kitware.com











    December 30, 2023
===============================================================================================================================================================================================================================








We propose a novel method for predicting image labels by fusing image content descriptors with the social media context of each image. An image uploaded to a social media site such as Flickr often has meaningful, associated information, such as comments and other images the user has uploaded, that is complementary to pixel content and helpful in predicting labels. Prediction challenges such as ImageNet <cit.> and MSCOCO <cit.> use only pixels, while other methods make predictions purely from social media context <cit.>. Our method is based on a novel fully connected Conditional Random Field (CRF) framework, where each node is an image, and consists of two deep Convolutional Neural Networks (CNN) and one Recurrent Neural Network (RNN) that model both textual and visual node/image information. The edge weights of the CRF graph represent textual similarity and link-based metadata such as user sets and image groups. We model the CRF as an RNN for both learning and inference, and incorporate the weighted ranking loss and cross entropy loss into the CRF parameter optimization to handle the training data imbalance issue. Our proposed approach is evaluated on the MIR-9K dataset and experimentally outperforms current state-of-the-art approaches.





§ INTRODUCTION


Multimedia data such as images and videos are being produced and shared at an unprecedented and accelerating pace in recent years. For example, on YouTube, video data is currently being uploaded at the rate of approximately 30 million hours a year. This drives a strong need to develop automatic tools to help users understand, organize, and retrieve images and videos from vast collections. While recent advances have been impressive, real-world multimedia, especially those shared on the image-sharing platform Flickr, can still be challenging to index and retrieve using only visual information, due to complex content, partial occlusion, and diverse styles and quality. 










Images in social media do not exist in isolation. As illustrated in Figure <ref>, a rich social multimedia database contains images, text information such as image title, description and comments, as well as user information (e.g., username, location, network of contacts), user image gallery, uploader-defined groups, and links between shared content. Most image recognition and label prediction methods depend entirely or primarily on pixel content, and do not make full use of commonly-available multimedia information to aid in automatic image labeling. We hypothesize that using social media context jointly with pixel information should improve the state-of-the-art in image labeling. Furthermore, we seek to understand the relative contribution of pixels, text and other information in predicting image labels.




We define our problem as an automatic image labeling based on inferring content labels Y, conditioned on an image I, and other related metadata information M. Our proposed solution is illustrated in Figure <ref>, which introduces a novel deep fully connected Conditional Random Field framework (we call “DCRF") that uses deep neural networks to compute the joint probability P(Y|I,M). CRFs have been commonly used in image segmentation problems where the model has one hidden node per pixel or grid-cell, and a vector of hidden nodes for a single image. Instead, we abstract up one layer and define one hidden node per image, instead of per pixel, over the entire dataset of images to form an image relationship graph. This results in having the vector of hidden nodes over the whole dataset with one node per image.

For pixel content descriptors, we exploitation popular image classification CNNs to extract a visual feature vector for each image or CRF node. To incorporate image title, comments, captions and other text, instead of using high-frequency words as tags <cit.>, we treat the text information as an unorganized and incoherent sentence and then fine-tune a popular network for sentence classification <cit.> as a text-level neural network to extract text features. In addition to textual similarity based on the text feature, we use associative metadata such as user sets and image groups to determine the edge weights in the fully connected CRF graph.

Our fully connected CRF establishes pairwise potentials on all pairs of images over the entire dataset. It combines the strengths of both CNN and CRF based graphical models in a unified framework. Inspired by Zheng et al. <cit.>, we formulate a mean-field approximation inference <cit.> for the CRF and model it as a Recurrent Neural Network (RNN). Hence our DCRF is an end-to-end CNN-RNN framework, incorporating the advantages of both convolutional and recurrent neural networks, while enabling standard back-propagation during training for network parameter learning.



In the most closely related work, McAuley et al. <cit.> has proposed a CRF framework using social-network metadata to solve the image labeling problem. Compared with McAuley's approach, we have two advantages. First, our image-level CNN makes full use of the existing popular CNN models to extract powerful visual features from images, which integrates of the advantages of CNN feature extraction for nodes in the CRF.

Second, rather than exploring the relational model based on high-frequency co-occurring words as tags, we exploit our text-level CNN and associative metadata to construct the fully connected CRF graph. The experiment section shows that our method results in significant performance improvement. 



Our main contributions are summarized as follows:


  * We propose a novel deep fully connected CRF framework DCRF that uses deep neural networks for image labeling with social network metadata. Deep CCN image features are fused with text features and network linkage information in an end-to-end deep learning formulation. 

  * Instead of using high-frequency words as tags, we propose to use a text-level CNN to exploit textual information. The fully connected CRF graph is built based on the features extracted from the text-level convolutional neural network, as well as the link-based metadata like user sets and image groups.

  * For both learning and inference, we model a mean field approximation inference <cit.> for the fully connected CRF as an RNN, to introduce the CNN-RNN formulation. We also incorporate the weighted ranking loss to handle the imbalance label distribution existing in the training data.

  * We evaluate the proposed DCRF on the MIR-9K dataset and achieve significantly improved performance compared to previous state-of-the-art approaches.







§ RELATED WORK

The related work can be divided into two categories: social media for labeling and CRF with deep neural networks.

Social media context for labeling. A set of tags associated with each image is commonly used in multimodal classification settings. Guillamumin et al. <cit.> explored the relationship between tags and manual annotations to recover annotations using a combination of tags and image content. Lindstaedt et al. <cit.> and Sigurbjornsson et al. <cit.> studied the problem of recommending tags that were obtained from similar images and similar users. Sawant et al. <cit.> and Stone et al. <cit.> investigates friendship information between users for tag recommendation in social networks. EXIF and GPS are two commonly used sources of metadata that come directly from the camera <cit.>. Such metadata can be used to help determine who captured the photo and where, and also provide informative signals for image labeling tasks. Our method differs from all these and also <cit.> in that we use a much larger range of social media information, including free-form text as well as links, with deep learning based pixel descriptors incorporated into our novel deep learning fully connected CRF framework.

CRF with deep neural networks. In recent years, there are several works about CRF with a convolutional neural network which incorporate CRF to model structures in both output and hidden feature layers in CNN. Chu Chao et al. <cit.> propose a CRF-CNN framework which can simultaneously model structural information in both output and hidden feature layers in a probabilistic way, and apply it to human pose estimation. Shuai Zheng et al. <cit.> introduce a new form of convolutional neural network that combines the strengths of CNN and CRF-based probabilistic graphical modeling. Zheng et al. <cit.> models conditional random fields for image segmentation task as recurrent neural networks, with the node features extracted from a convolutional neural network. Chandra et al. <cit.> propose a structured prediction model that endows the Deep Gaussian Conditional Random Field with a densely connected graph structure. In these works, CNNs are integrated into CRF models and perform as feature extractors. Similarly, the two CNNs (image-level CNN and text-level CNN) in our proposed DCRF framework also work as powerful feature extractors in image labeling using social metadata. However, in addition to this, our text-level CNN is also used to help build the fully connected CRF graph, and both the learning and inference is under the united CNN-RNN framework, which distinguishes our proposed DCRF from the existing approaches.




§ PROPOSED APPROACH

In this section, we will describe in detail the proposed Deep fully connected CRF framework (as illustrated in Figure <ref>) with deep neural networks.




 §.§ CRF framework

Our probability framework is based on a fully connected conditional random field (CRF). This captures both unary dependencies between image labels, Y={y_1, y_2, …, y_N} (with binary value indicating if the image has this class label, y_n = 1 , or not, y_n = 0), and the input features (e.g., image features and metadata), as well as the pairwise dependencies between pairs of labels and the input features to produce the conditional probability P(Y|I,M) = P(Y| x, M), where x are the raw image features derived from the image set I. 






The labels are treated as binary hidden nodes in the CRF and the image features x, and metadata M, are used in the observation nodes. Therefore, the conditional probability of the fully connected CRF can be defined as:

    P(Y|I,M)    = P(Y| x, M) 
       = 1/Zexp(∑_i=1^NA(y_i,  x_i) 
         + ∑_i=1^N∑_∀ j ≠ i B(y_i, y_j, M)),

where Z is the normalization constant that depends on x and M, while A is the unary function based on the image information x, and B is the pairwise potential function based on the metadata M. The unary potentials are single image potentials, while the pairwise potentials are between pairs of images. 
For simplicity, a separate binary CRF model can be learned for each category. 






















 §.§ Unary function with image-level convolutional neural network

The goal of the image-level convolutional neural network (CNN) is to extract feature vectors that are compact, representative, and can capture the most related visual information for the decoder. The rapid development of deep convolutional neural networks have had great success in large-scale image recognition task <cit.>, object detection <cit.> and visual captioning <cit.>. High-level features can be extracted from upper or intermediate layers of a deep CNN network. Therefore, a set of well-tested CNN networks can be used in our framework. 

We use VGG-19 <cit.> and ResNet-152 network <cit.> for our framework. In this paper, for each category, we modify the original network by changing the number of outputs in the last layer from 1000 to 2 and fine-tune to conduct the binary classification. x_i in Equation <ref> is the feature vector extracted from the second last fully connected layer (i.e., the 18-th layer in VGG-19 and the 151-th layer in ResNet-152) for i-th instance. Then we can define the unary potential function as

    A(y_i,  x_i) =  w_A^y_i x_i +  b_A^y_i,

where y_i is either 1 or 0, and w_A^y_i, b_A^y_i are the parameters we need to learn.



 §.§ Pairwise potential with text-level convolutional neural network and other meta information

Unlike previous work that tries to make full use of text information in the metadata by exploring the co-occurrence of high frequently used words as tags, we treat all the texts including title, description and comments information associated with an image as an unorganized incoherent sentence or a bag of words. Then we can train a text-level convolutional neural network to extract the feature vectors. In principle, any sentence convolutional neural networks can be used in our framework. To make it simple, we use Kim's sentence network <cit.>, which is composed of one convolutional layer, one pooling layer, one dropout layer, one fully-connected layer and output with softmax activation function. 

In this paper, we extract the 128-dimensional dropout layer to measure the similarity between any two images at the text-level. We define text similarity as

    S_text(i, j) = exp(-| x_i^text- x_j^text|^2/2θ_text),

where the degree of nearness and similarity is controlled by the θ_text parameter.

Besides the text information, we also use the link-based metadata such as user sets and image groups <cit.>. A user set associates with a collection of images uploaded or collected by the same user. Image groups are community-curated, and are usually images belonging to the same concept, scene or event are uploaded and shared by the social network users. Both user sets and image groups have vocabularies, i.e., T_set and T_group, and each image x_i has two subsets, t_i^set and t_i^group. We calculate the distance between any two nodes/images using the Jaccard similarity between their user sets and image groups as:

    d(i, j, M_set) = 1 - |t_i^set∩ t_j^set|/|t_i^set∪ t_j^set|,


    d(i, j, M_group) = 1 - |t_i^group∩ t_j^group|/|t_i^group∪ t_j^group|
 
and get the corresponding similarities 

    S_set(i, j) = exp(-d(i, j, M_set)^2/2θ_set),


    S_group(i, j) = exp(-d(i, j, M_group)^2/2θ_group),

where both θ_set and θ_group are the parameter to control the degree of similarity.

Intuitively, two nodes/images which are more similiar are more likely to share the same labels and should be able to affect each other more than others. Therefore, similarity is close related to the pairwise potential and we can define the pairwise potential as 

    B(y_i, y_j, M)) =  μ(y_i, y_j)∑_k∈{text, set, group} w_B^k S_k(i, j),

where μ(·,·) is label compatibility function, and w_B^text, w_B^set, w_B^group are the 2×2 parameters to be learned from the training data. 

















 §.§ Learning and inference under neural network

Both image-level CNN and text-level CNN are trained separately. With the pre-trained networks, we are able to extract the node features and textual features to build the fully connected CRF, in which we also take user sets and image groups into account. Unfortunately, the parameters θ_text, θ_set and θ_group cannot be calculated efficiently since their gradients involve a sum of non-Gaussian kernels, which are not amenable to the same acceleration techniques. Therefore, we resort to take grid search on a holdout validation set for determining all these three parameters, and learn the parameter w = [ w_A,  w_B], b_A and μ(·,·) only.



We resort to a mean field approximation inference <cit.> which computes a distribution Q( X) that minimizes the KL-divergence D(Q||P) among all the approximated distributions Q that can be experessed as a product of independent marginals, Q( X) = ∏_i Q_i [For simplicity, we use Q_i to indicate Q( x_i) and therefore Q_i(y) indicate the probability of x_i being labeled as label y.] and

    Q_i(y) = 1/Z_iexp{- w_A^y  x_i - Q_i^'(y)},

where

    Q_i^'(y) = ∑_y^'μ(y, y^')∑_k∈{text, set, group} w_B^k ∑_∀ j ≠ iS_k(i, j)Q_j(y).


The update equation in Equation <ref> leads to the inference steps, as seen in Algorithm <ref>. Inspired by the spirits in Zheng et al.'s work <cit.>, we can implement the algorithm as a combination framework with both CNN and RNN. To be specific, line 1 and line 2 are associated with image-level CNN and text-level CNN, respectively. Line 3 can be regarded as a preprocessing step. Line 4 can be modeled as a fully connected layer. Line 5 is a softmax layer with unary potential as input. Line 7 can be regarded as linear combination of matrix multiplications, since the parameters θ_text, θ_set and θ_group are determined by grid search validation and therefore S_k(·,·) is fixed during running the algorithm <ref>. Line 8 can be implemented as a convolution with a 1x1 filter with three input channels and one output channel. Line 9 is another convolutional layer in which the number of both input and output channels are both two for the binary classification case. Line 10 is element-wise subtraction from the unary potential U_i. Line 11 is another softmax layer. Obviously, the layers associated with line 7 to line 11 construct a recurrent neural network (RNN).

Both learning and inference can be conducted under the united CNN-RNN framework which we implement in PyTorch. For the loss function, besides the L2 regularization on w_A, we use weighted binnary cross entropy and pairwise ranking loss 

    Loss(Q, Y) = ∑_i=1^N -y_i/N_+logQ_i(y_i) -1-y_i/N_-logQ_i(1-y_i)
           +∑_i=1^N y_i/N_+(1 - (Q_i(y_i)-Q_i(1-y_i)) 
           +∑_i=1^N 1-y_i/N_-(1 - (Q_i(1-y_i)-Q_i(y_i)) + λ‖ w_A‖_2,

to handle the possible imbalance distribution of positive/negative instances in the training data and ensure a good probability ranking. Note that N_+ and N_- in Equation <ref> are the number of postive training instances and the number of the negative training instances, respectively. λ is the regularization parameter and we set 0.1 for VGG-19 and 0.001 for ResNet-152. We initialize all parameters using the method of <cit.> and optimize using stochastic gradient descent RMSProp with a fixed learning rate of 0.1. 















































§ EXPERIMENT



We conduct experiments to verify the effectiveness of the proposed approach on the MIR-9K dataset, a subset of the MIRFLICKR <cit.> dataset which is available under Creative Commons licenses. 
It worths mentioning here that we do not evaluate on datasets like NSU-WIDE dataset <cit.> since there are only tag words available on the official website, without the original text information (e.g., image title, description and comments), which prevent us from evaluating our text-level CNN in Section <ref>. The MIR-9K dataset contains 6000 training instances and 3182 testing instances with 24 categories: animals, baby, bird, car, clouds, dogs, female, flower, food, indoor, lake, male, night, people, plant life, portrait, river, sea, sky, structures, sunset, transport, tree, and water. 
It involves a set 3,213 users, a collection of 34,942 words and 17,687 image groups.
The data distribution 
is shown in Figure <ref>, where there are imbalance issues among different categories. 

For measurement metrics, we report the average precision (AP), recall, precision and accuracy over all 24 categories for the sake of comparison with published algorithms. 






 §.§ Effectiveness of the text-level CNN

To evaluate the effectiveness of the text-level CNN to our proposed DCRF, we first define the CRF only with the textual similarity defined in Equation <ref>, and denote the method as DCRF-Text. We then replace the textual similarity with the tag Jaccard similarity calcualted in  <cit.> (with 5000 high frequent occurring words
as tags) for any two nodes/images to build the CRF, and mark the competing algorithm as DCRF-Tag. Note that both DCRF-Text and DCRF-Tag use the same visual node features obtained from the VGG-19 or ResNet-152 network. We also provide two baselines that use text information and image information independently, i.e., CNN-Text, VGG-19 and ResNet-152, respectively.

The performance results are summarized in Figure <ref> and <ref>. As we can see, (a) both VGG-19 and ResNet-152 perform much better than CNN-Text in AP, recall, precision and accuracy, which indicates image information is more helpful for image labeling when compared with the text information. (b) Also both DCRF-Text and DCRF-Tag work better than CNN-Text, VGG-19 and ResNet-152 in all four metrics, which indicates the text information complementary to image information and useful for improving the labeling accuracy. (c) Regardless of using the VGG-19 or ResNet-152 network to extract the node/image features, DCRF-Text outperforms DCRF-Tag, which clearly demonstrate that the text-level CNN of our DCRF is better able to explore the underlying information in text than just relying on the top frequent words as tags. 

To analyze why our proposed DCRF-Text is able to outperform DCRF-Tag, we visualize the top 20 words in decreasing order of frequency occurring among 6000 training examples. Due to space limitations, we only present 4 categories in Figure <ref>. 
 We observe that the top frequently co-occurring words such as “love", “photo", “great", “group", 
“added", “nice" et. al convey little information relative to any of the prediction 24 categories.  Instead, we resort to a text-level CNN to explore the underlying information and use the textual similarity based on the features extracted from the text-level CNN to build the fully connected CRF graph, which explains why our proposed approach DCRF makes slightly better use of text information.



 §.§ Effectiveness of the metadata for image labeling

In Section <ref>, text information has been proved to able to boost the performance for the image labeling accuracy. We also want to see whether the link-based metadata such as user sets and image groups, can produce positive effect on the image labeling. Using the same node features extracted from either the VGG-19 or ResNet-152 network, we first define the CRF graph with a single type of metadata (i.e., text, user sets and image groups) and get three versions of DCRF: DCRF-Text, DCRF-Set and DCRF-Group. Then we define the CRF with the combined these three types of metadata together, and denote the combined version as DCRF-TSG.

 
We summarize the results in Figure <ref>. As we expect, each of all these DCRF-Text, DCRF-Set and DCRF-Group perform better than VGG-19 and ResNet-152, which suggests that all these three types of metadata are helpful for image annotation. Among these three types of metadata, using text information provides the greatest improvement in AP compared to the other two. However, 
combining all three types into the DCRF-TSG model produces the greatest performance in all four metrics, regardless of using the VGG-19 or ResNet-152 network as node feature extractor. Such observations demonstrate that the metadata as text, user sets and image groups are complementary to each other and can be used for boosting the quality of image labeling. 









 §.§ Compare with state-of-the-art approach

In addition to the text-level CNN model CNN_text <cit.>, and four image-level popular CNN models AlexNet_img <cit.>, VGG-19_img <cit.>, ResNet-152_img <cit.> and DenseNet-201_img <cit.>, we compare our proposed DCRF with the most closely related work, i.e., McAuley et al's CRF algorithm <cit.>, denoted as McAuley-CRF, which explores the social-network metadata such as image groups and comments, and utlizes structured learning techniques to learn model parameters. We also compare with one deep learning related work, i.e., Johnson et al's neighbor-based CNN algorithm <cit.>, denoted as Johnson-NCNN, which use image metadata in a nonparametrical manner to generate neighborhoods of related images using Jaccard similarity and then uses a deep learning to blend visual information from the image and its neighbors. 


For fair comparison, we provide two versions of deep learning models (i.e., the VGG-19 and ResNet-152 networks) for Johnson-NCNN, and mark them as Johnson-NCNN_vgg and Johnson-NCNN_res, respectively. Obviously, our DCRF has two versions, i.e., DCRF_vgg and DCRF_res. To better show the effectiveness of the loss function we use in Section <ref>, we get six versions, i.e., DCRF_vgg-BCE,  DCRF_res-BCE, DCRF_vgg-RLoss,  DCRF_res-RLoss, DCRF_vgg-BCE+RLoss,  DCRF_res-BCE+RLoss, in which “BCE" indicates binary cross entropy and “RLoss" means pairwise ranking loss in the binary classification cases.




The results are summarized in Table <ref>, from which we can observe: (a) all four image-level CNNs perform better CNN_text, and VGG-19 and ResNet-152 are the top 2 image-level CNN models on the MIR-9K dataset; (b) our proposed DCRF significantly outperforms the McAuley-CRF approach, which shows the big advantages of using deep neural networks in CRF; (c) with the same deep node features extracted from either the VGG-19 or ResNet-152 network, all versions of our DCRF are able to obtain improvement in all four metrics when compared to using textual or visual information only; 
(d) rank loss function works a little better than cross entropy loss function in all four metrics; 
(e) the performance of our DCRF_vgg-BCE+RLoss and DCRF_res-BCE+RLoss are slightly higher than those of John-NCNN_vgg and John-NCNN_res in AP and accuracy and significantly higher in recall and precision, and our DCRF_vgg-BCE+RLoss achieves the best performances in AP, precision and accuracy. 





 §.§ Visualization

For better understanding of our porposed DCRF, we visualize some testing examples with DCRF_vgg and take VGG-19 and John-NCNN_vgg as baselines in Figure <ref>.
As we can see, 
both DCRF_vgg and John-NCNN_vgg benefit from the metadata information for improving the quality of image labeling. Overall, our proposed DCRF achieves the higher quality of labels. Moreover, our proposed DCRF_vgg is able to predict some categories that are not clear or even occluded in images, such as “car" and “tree" in the middle two examples at the bottom row.






§ CONCLUSION

In this paper, we propose a novel deep fully connected CRF based framework DCRF with deep neural networks for image labeling using social network metadata. In such a framework, CNNs are used to extract powerful visual features for nodes/images and textual features to explore the underlying information embedded in text. The fully connected CRF graph is built based on the textual similarity and the link-based metadata like user sets and image groups. With the mean-field approximation modeled as an RNN, our proposed framework DCRF becomes a joint end-to-end CNN-RNN formulation, which combines the strengths of both CNNs and RNNs. The experimental evaluation on the MIR-9K dataset demonstrates that our proposed DCRF framework outperforms state-of-the-art approaches <cit.>.

Our future work includes investigating more effective meta information, and improving the efficiency of the current DCRF framework to handle more complicated real-world application problems.



ieee



