Improving Multi-label Recognition using Class Co-Occurrence Probabilities
Samyak Rawlekar Shubhang Bhatnagar Vishnuvardhan Pogunulu Srinivasulu Narendra Ahuja










Improving MLR using Class Co-Occurrence Probabilities







Rawlekar et al.



University of Illinois Urbana-Champaign, IL, USA
{samyakr2,sb56,n-ahuja}@illinois.edu
Vizzhy, USA
vishnu@vizzhy.com






Improving Multi-label Recognition using Class Co-Occurrence Probabilities
    
    Samyak Rawlekar 1 Equal contribution. Shubhang Bhatnagar 1 * Vishnuvardhan Pogunulu Srinivasulu 2 Narendra Ahuja 1

    April 29, 2024
============================================================================================================================




Multi-label Recognition (MLR) involves the identification of multiple objects within an image. To address the additional complexity of this problem, recent works have leveraged information from vision-language models (VLMs) trained on large text-images datasets for the task. These methods learn an independent classifier for each object (class), overlooking correlations in their occurrences. Such co-occurrences can be captured from the training data as conditional probabilities between a pair of classes. We propose a framework to extend the independent classifiers by incorporating the co-occurrence information for object pairs to improve the performance of independent classifiers. We use a Graph Convolutional Network (GCN) to enforce the conditional probabilities between classes, by refining the initial estimates derived from image and text sources obtained using VLMs. We validate our method on four MLR datasets, where our approach outperforms all state-of-the-art methods.
























§ INTRODUCTION




Multi-label recognition (MLR) involves identifying each of the multiple classes from which objects are present in an image. It has many applications such as identifying all different: diseases evident in a chest x-ray  <cit.>, products in a query image for e-commerce <cit.>, and food items in a plate for diet monitoring systems <cit.>.

MLR is more challenging than classifying images having a single object <cit.> because an image may contain combinatorially large mix of classes, for which learning would require exponentially larger number of images (O(2^N) images for N classes) than for Single label recognition (SLR). The objects may also occur in different layouts so recognition either requires object segmentation and recognition of each segmented object independently, or recognizing the object mix from the features measured over the entire image.


Several approaches <cit.> have taken the latter approach, namely recognition from image level features. Further, these approaches also reduce complexity by recognizing the presence of each object in an image independent of the others that may also be present. Training here amounts to learning independent classifiers for each object, which are then used to detect the corresponding objects, both using image level features. Apart from not segmenting the image and features into those for different objects, these methods also neglect the evidence for the presence of an object provided by the context of other objects. In practice, many objects are in sets, making their occurrences interdependent. Using independent classifiers neglects the mutual information present, which, if used, could enhance the performance of individual classifiers. This is particularly important in view of the already larger amount of data needed for MLR, and the relatively small sizes (vs SLR) of available annotated MLR datasets (because multiple classes present in an image require more annotation effort than required for SL images).

 To mitigate the paucity of labeled data, recent MLR approaches <cit.> have focused on adapting large Vision Language Models (VLMs) e.g. CLIP <cit.>, ALIGN <cit.>, OpenCLIP <cit.> for the task. Instead of finetuning the VLM on small MLR datasets,  these approaches <cit.> rely on learning a pair of positive/negative text prompts associated with each class; the prompts associated with a class are learned by maximizing/ minimizing the similarities of their embeddings with those of the embeddings extracted from images containing objects of the class. The additional information captured by the prompts constrains possible matches between the data and the desired labels, in turn limiting the number of parameters needed to be learned. This helps mitigate overfitting on small datasets. At test time, whether a class is present in a given image is ascertained by measuring the similarity of the image embeddings with embeddings extracted from previously learned positive/negative prompts for the class. However, the learning of prompts here is done independently for each class, again neglecting the class co-occurrences.


We propose a two-stage framework that leverages the knowledge of VLMs but injects the co-occurrence information into the models. We obtain an initial estimate of the evidence logits for each class in a subimage in terms of the match between the embeddings of the subimage and those of the positive and negative text prompts associated with the class. Results from the subimages are aggregated to obtain logits for all classes across the image. These independently extracted subimage logits are refined to enforce prior knowledge of the joint probabilities of pairs of classes present in different subimages. Given that a class is present in a training image, the conditional probabilities of other classes being also present are measured from the frequencies of observing those classes in the image. Since the prior probability of a class is known from the VLM output, we can combine it with the conditional probabilities of other classes to obtain joint probabilities of class pairs. Enhancement of the outputs of the independent classifiers by using conditional probabilities is carried out through a graph convolutional network (GCN). GCN thus utilizes the conditional probabilities to improve upon the outputs of the independently obtained class estimates using the vision-language model. As commonly done, we compensate for the differences in the frequencies of different classes occurring in the training images by reweighting the estimated probabilities of different classes to remove the class bias in the training data.

We test our approach on four benchmarks: MS-COCO-small (5% of the training set), PASCAL VOC, FoodSeg103, and UNIMIB-2016. The first two are commonly used for MLR, whereas we have two additional datasets that have been used in other contexts <cit.>. The number of images in each of these datasets is small compared to even many SLR datasets, although MLR calls for larger datasets. This makes MLR here even harder.
Our experiments show that the use of inter-class influence in the second stage of our framework significantly improves performance over the state-of-the-art methods, which detect each class independently. As expected, the advantage is higher for classes for which VLM yields low accuracy but which frequently co-occur with other classes for which VLM accuracy is higher.  
We also show that our loss re-weighing greatly improves the performance on datasets where there is a significant class bias.

Our contributions:

  
  * We propose a two-stage framework to adapt VLMs for MLR with limited annotated data, by enhancing the VLM based independent class estimates obtained in the first stage, with conditional probability priors extracted from the dataset, using a GCN.
 
  
  
  * We validate our algorithm quantitatively using mean average precision (mAP) on four MLR datasets. Our method surpasses the previous SOTA MLR approaches by more than 2% (COCO-14-small), 0.4% (VOC-2007), 3.9% (FoodSeg103) and 11% (UNIMIB2016). 


























































































































  

  















§ RELATED WORKS




 §.§ Multi-Label Recognition


Multi-label recognition is an important, well-studied problem in computer vision, with a wide range of approaches being proposed to tackle it <cit.>. An important line of work has focused on learning disjoint binary classifiers for identifying each class of objects in an image <cit.>. These approaches require large labeled datasets for training. They make no use of information that can be derived from modeling the co-occurrence of different classes, which is especially important when only a small amount of annotated data is available for training.

Other works have proposed to use recurrent neural networks (RNNs) to model label dependencies in an image <cit.>. Specifically, they cast MLR into a sequence prediction problem, using beam search to find a sequence of objects having the highest likelihood of being present in the image. Like our method, these methods also model label dependencies, but do so implicitly via the hidden state of RNNs. This requires vast amounts of labeled data to learn them. Recent approaches for MLR have proposed the use of VLMs to improve MLR performance when only a limited amount of labeled data is available. 



 §.§ Vision-Language Models for MLR

VLMs learn representations that are transferable to a wide range of downstream tasks such as classification <cit.>, retrieval <cit.>, and segmentation<cit.> by aligning hundreds of millions of image-text(prompts) pairs. Such approaches commonly focus on learning prompts suitable for these downstream tasks <cit.>. <cit.> adapts VLMs for MLR, proposing to learn a pair of prompts associated with the presence/ absence of each class. Text embeddings extracted from the learned prompts are used to gather local evidence from the image features extracted by the VLM, which is then aggregated and combined. On the other hand, SCPNet <cit.> is another VLM based approach for MLR which uses the similarity between the class prompt embedding from VLMs to train a classifier for each class. In these methods, classifiers for each class are independent of those for other classes, not making use of any contextual information during inference on an image. 

































 §.§ Long tailed Learning

The distribution of frequency with which objects belong to a class in real-world images often follows a long-tailed distribution<cit.>. Networks trained for multi-class classification on such data tend to perform poorly on the tail classes which have less data available. Several approaches have been proposed to mitigate this issue including data augmentation (augment the tail classes) <cit.>, data re-sampling (sample images to obtain balanced distribution) <cit.>, adjusting classifier margins (classification thresholds vary for every class)<cit.> and loss re-weighing  <cit.> being popular. We use loss re-weighing to mitigate the effect of label imbalance on our method when it is trained to model label conditional probabilities. 








§ METHOD



Suppose in a given set of images, 𝒟 = {x_i}, i ∈{1 |𝒟|}, every image 𝐱_𝐢 may contain objects from up to N classes. The image is thus associated with N  labels 𝐲_𝐢∈{0,1}^N where y_i^j denotes the presence or absence (1 or 0) of the j-th class in the image. Then the MLR problem requires identification of all labels associated with any input image.


Our approach in this paper uses a VLM  g_ϕ, parameterized using weights ϕ (a pair of encoders g_ϕ,img, g_ϕ, text). VLMs are pretrained to align image and textual features over large datasets to learn features suited for various tasks/domains. As mentioned in Sec. <ref>, these models associate a pair of positive and negative text prompts {𝐭_𝐣,+, 𝐭_𝐣,-} with each class j (complete set denoted by ψ). A text encoder g_ϕ, text extracts text embeddings from each of these prompts, gives them to an image-text feature aggregation head  p, which matches visual features extracted from different subimages with the text embeddings, and combines them to obtain an initial set of logits for each class in the image. We then use a GCN f_θ with weights θ to refine the logits output by p, by leveraging the statistical co-occurrence of classes observed in the training dataset. An overview of our proposed method is given in Figure <ref>. 



The following subsections present the various parts of our method.









 §.§ Initial Logits Estimation


We use a VLM as a feature extractor and initial classifier for our method. The VLM's image encoder does spatial pooling of windows in the final layer to obtain a single d dimensional feature vector for a single-label image x_i. This is not suitable for MLR case as spatial pooling operation combines the features of multiple objects in different regions of the image, with overall features being dominated by those extracted from a single object. We remove the pooling layer of the image encoder, using it to get features g_ϕ, img(𝐱_𝐢) = 𝐳_𝐢 (of shape d × H × W) for a given image x_i, hence preserving information from the individual windows.
 
 

 Our image-text feature aggregation head p is similar to <cit.>. For each class j, it learns a pair of text prompts {𝐭_𝐣,+, 𝐭_𝐣,-}, which are projected to d-dimensional embeddings 𝐫_𝐣,+, 𝐫_𝐣,- using g_ϕ, text. Cosine similarity of the d-dimensional image features at a particular point (h,w) with 𝐫_𝐣,+ indicates the presence of the class, while similarity with 𝐫_𝐣,- indicates its absence. These similarities are aggregated and used by p to give logits p(𝐳_𝐢) for the image. 
 
 
 

 

 §.§ Refining Logits using Conditional Prior

 
 We refine the logits p(𝐳_𝐢) using a GCN, which ensures conformity with the conditional probability priors extracted from the training dataset.


  §.§.§ Estimating Label Conditional Probability Prior:

To derive the label prior from the dataset, we first calculate the label co-occurrence matrix C_N × N = (c_mn) over training dataset 𝒟. Each entry c_mn is given by 

    c_mn = ∑_i = 0^|𝒟| y_i^m× y_i^n

The c_mn denotes the number of times that objects belonging to classes m and n occur together in an image. Using this, we calculate an estimate of conditional probability matrix A_N × N = (a_mn), where each entry gives an estimate for the probability P(y_i^n= 1 | y_i^m=1):

    a_mn = P̂(y_i^n= 1 | y_i^m=1) = c_mnc_mm









  §.§.§ GCN for Refinement:


We refine the logits p_ψ(𝐳_𝐢)  using the GCN f_θ which uses the conditional probability matrix A to define the connection weights between its N nodes. Specifically, given that f_θ has L layers, each layer calculates:

    H^l = ρ(AH^l-1 W^l)
 
where H^l-1 is the output vector of the previous layer and ρ is a non linearity (Leaky ReLU). H^0 is defined as the input logits p_ψ(𝐳_𝐢). 
W^l are learnable weights for each layer. Using a GCN layer ensures that the logits are refined using information from only those nodes used for computing the logits, reducing the number of parameters learned while also taking advantage of the conditional probability estimates. After passing through multiple layers of the GCN, we get the updated predictions f_θ(p_ψ(𝐳_𝐢)). We add the initial logits to the updated logits to obtain our refined logits prediction  p_ψ(𝐳_𝐢) + f_θ(p_ψ(𝐳_𝐢))




 
 






































 §.§ Training



We train the image-text feature aggregation module p and the GCN f_θ, while freezing the VLM g_ϕ. We adopt the widely used Asymmetric Loss (ASL) <cit.>, a modified version of the focal loss, to train our network for MLR. 

ASL <cit.> addresses the inherent imbalance in MLR caused by the prevalence of negative examples compared to positive ones in training images. Similar to focal loss <cit.>, ASL underweighs the loss term due to negative examples. However, it does so using two focusing parameters (γ_+ and γ_- ) instead of one (γ) used by focal loss.
However, ASL does not address the issue of sample imbalance, caused by some classes having fewer examples in the dataset. Towards this, we add a loss re-weighting term (α) to ASL. Our re-weighed ASL (RASL) is defined as:

    ℒ_RASL(ŷ_i^j) =    α_j(1-ŷ_i^j)^γ_+log(ŷ_i^j)  when  y_i^j =1 
       α_j(ŷ_i, δ^j)^γ_-log(1-ŷ_i, δ^j)  when  y_i^j=0

where ŷ_i^j represents the corresponding prediction associated with label y_i^j; ŷ_i, δ^j = max(ŷ - δ, 0), with δ representing the shifting parameter defined in ASL; 
and α_j is the re-weighting parameter for class j, defined as:

    α   = ( a_jj/∑_j=1^N a_jj)^-1


Then the total loss over the dataset |𝒟 | is given by:

    ℒ_total = ∑_i=1^|𝒟|∑_j=1^Nℒ_RASL(ŷ_i^j)











 
 

  











§ EXPERIMENTS


In this section, we discuss the datasets used, implementation details of our approach, evaluation metrics and provide a thorough analysis of our approach.
 

 §.§ Datasets

We evaluate our method on four different MLR benchmarks: MS-COCO 2014-small and PASCAL VOC 2007, which are widely used MLR benchmarks, as well as FoodSeg103 and UNIMIB 2016, which are smaller MLR datasets suitable for testing in the low data regime. Details of these datasets are given below:
 MS-COCO 2014-small:  MS-COCO <cit.> is another popular MLR dataset and consists of 82,081 training images and 40,504 validation images with objects belonging to 80  classes. To evaluate our methods performance in the low data regime, we use MS-COCO 2014-small, which is a small, randomly selected subset comprising 5% of MS-COCO 2014 which amounts to 4014 images. During testing, we use the complete validation set.


 PASCAL VOC 2007: VOC <cit.> is a widely used outdoor scene MLR dataset consisting of 9,963 images from 20 classes. We follow the standard trainval set for training and use the test set for testing.
 

FoodSeg103:  FoodSeg103 <cit.> serves as a benchmark dataset for food segmentation and multi-label food recognition. It consists of 4983 training images and 2135 test images, with a total of 32,097 food instances belonging to  103 different food classes. The number of images per class follows a long-tail distribution typical of real-world datasets. We use the standard train-test data split.


UNIMIB 2016: UNIMIB <cit.> is another multi-label food recognition dataset. It consists of 1027 images with 3616 food instances spanning 73 classes. Similar to FoodSeg103, UNIMIB also follows a long-tail distribution typical of real-world datasets. We comply with the official train-test split. 



 §.§ Implementation Details


In our experiments, we use CLIP (Contrastive Language-Image Pre-Training) <cit.> as the VLM. Consistent with recent works that use VLMs for MLR  <cit.>, we select ResNet-101 as the visual encoder and standard transformer within CLIP as the text encoder. Both encoders are kept frozen during our experiments, and we train the GCN and learnable prompts. Following <cit.>, we resize the images to 448 × 448 for COCO and VOC datasets and to 224 × 224 for UNIMIB and FoodSeg103. Similar to previous works <cit.>  we apply Cutout <cit.> and RandAugment <cit.> to augment training images. We use a 3-layer GCN network for all our experiments. We use SGD for optimizing parameters with an initial learning rate of 0.002, which is reduced by cosine annealing. We train for 50 epochs and use a batch size of 32. We set the loss hyperparameters in Eq. <ref> as γ_- = 3, γ_+ = 1 and δ = 0.05 . We conduct all experiments on a single RTX A4000 GPU.






 §.§ Evaluation Metrics

To evaluate the performance of our approach on the four MLR datasets, we use standard metrics, also used by previous MLR approaches <cit.>. The metrics include the commonly used mean average precision (mAP) as well as class and overall precisions (CP and OP), recalls (CR and OR), and F1 scores (CF1 and OF1). mAP is obtained by calculating the mean of individual average precision (AP) values over all classes. For each class, AP is computed as the area under the Precision-Recall curve. 





























 §.§ Results



We compare our approach primarily with DualCoOp <cit.> and SCPNet <cit.> which use VLMs like our method, on all four standard benchmarks discussed earlier. As seen in Table <ref>, our method outperforms DualCoOp by 0.4% and SCPNet by  7.0% mAP on the VOC-2007. On COCO-small, our method outperforms DualCoOp by 2.4% and SCPNet by 3.3% mAP.


On the FoodSeg103 dataset, our approach significantly improves upon 
DualCoOp by 3.9% and SCPNet by 4.1% mAP. In the UNIMIB dataset, our method achieves substantial performance gains of 
14.1% over DualCoOp and 12.2% mAP over SCPNet. 

Furthermore, for VOC, we extend our comparison to approaches that do not use VLMs and instead rely on complete fine-tuning<cit.>. These approaches also use a ResNet-101 backbone similar to our visual encoder, but the backbone is initialized with weights pre-trained on ImageNet instead <cit.>. Our method also outperforms these methods. More detailed comparison can be found in Table. <ref>. 





 §.§ Impact of the Strength of Conditional Probability on Performance


In this section, we determine the impact of the strength of conditional probability of a pair of classes on MLR performance on the COCO-small dataset. Specifically, we observe how the improvement in average precision of a class of objects (ΔAP) brought by our method varies with the average conditional probability of the class paired with the top three other classes it co-occurs the most with. Note that we choose to average the top three values of conditional probabilities of the class because the COCO dataset typically contains an average of around three objects per image. The improvement in (ΔAP) for a class = AP achieved by logits after refinement - AP achieved by the raw VLM logits before refinement.

We visualize the variation in ΔAP with the avg. conditional probability in Figure <ref>, where we observe an increasing trend of  ΔAP  with increase in the average of the top-3 conditional probabilities for a given class. Note that for ease of visualization of the scatterplot, we use bins of size 0.02 to group together classes having similar average conditional probabilities. The points represent the average ΔAP value of all classes within the respective bin.

This implies that classes having stronger conditional probabilities with other classes benefit more from our approach of refining logits using conditional probabilities, as is intuitively expected. 



 §.§ Performance on Classes that are Difficult to Recognize



In this section, we empirically explore the impact of our approach on classes that are difficult to recognize when using image features exclusively. For concreteness, we focus our analysis on the 10 classes in FoodSeg103 and UNIMIB datasets on which the previous state-of-the-art approach (DualCoop<cit.>) performs (in terms of CF1) the worst. 

Table <ref> compares the performance of our method on these classes with the previous state-of-the-art DualCoOp<cit.>. We see that our method significantly improves the performance of DualCoOp<cit.>, which relies solely on VLMs without modeling any conditional probabilities. Specifically, we observe a growth of 22.3% in CP, 33.9% in CR and 34.8% for CF1 on UNIMIB2016. On FoodSeg103, our method significantly improves CP, CR and CF1, by 15.6%, 7.2% and 11.89%, respectively.
This underscores the importance of the information obtained by modeling joint class probabilities in recognizing classes of objects that are difficult to recognize from image features alone.


 



 

 §.§ Effect of Loss Reweighing

 
In this subsection, we investigate the effects of our loss reweighing strategy for UNIMIB2016 and FoodSeg103, which exhibit significant class imbalance. We analyze its impact on performance on  (1) All classes as a whole and (2) Classes that are difficult to recognize using only visual features, and hence have a greater reliance on information obtained from conditional probabilities.

 

(1) All classes as a whole: As observed in Table <ref>, loss re-weighing improves the performance of our method by 1.6% and 7.8% in mAP on FoodSeg103 and UNIMIB2016, respectively. 

This demonstrates the utility of using loss re-weighing when training a method modeling the joint probability distribution of classes as opposed.



(2) Classes that are difficult to recognize using only visual features: As seen in Table <ref>, loss re-weighing also significantly boosts the performance of our method on these classes. It improves CP, CR and CF1 by 13.9%, 4.4% and 9.7%, respectively on the FoodSeg103 dataset and by 15.7%, 4.5% and 14.2%, respectively on the UNIMIB2016 dataset. Note that these increases are higher than corresponding gains observed for all classes in the dataset, signifying that loss re-weighing delivers larger benefits to classes more reliant on conditional probabilities for recognition (as opposed to those that derive more information from initial logits estimated from logits)




 
 

























§ CONCLUSIONS

In this paper, we present a novel two-stage framework for multi-label recognition when only a small number of annotated images are available. Our framework builds on recent methods that make use of VLMs to counter this paucity of labeled data but overlook information derived from co-occurence of object pairs. Our framework refines the logit predictions made by VLMs adapted for multi-label recognition by leveraging known conditional probabilities of class pairs derived from the training data distribution. Specifically, we use a graph convolutional network to enrich the logits predicted by the VLM with information from conditional probabilities of classes. Our method outperforms all state-of-the-art approaches on 4 MLR benchmarks: COCO-14-small, VOC 2007, FoodSeg103 and UNIMIB2016 in a low data regime, demonstrating the utility of modeling class co-occurrence in such cases.






§ LIMITATIONS


(1) If the independent classifiers learned by state-of-the-art approaches (relying on only visual information, not modeling the conditional probability of class pairs) are strong, and characterized by a high average precision (AP) of each class, our method would yield lower improvements. However, in practice, many MLR datasets are not very large, with independent classifiers learned from them being relatively weak. MLR on such datasets is likely to benefit significantly from our method. 

(2) As shown in Figure. <ref>, the advantage provided by our method is higher when the conditional probability of pairs of classes co-occurring in an image is higher. For images that consist of objects which are rarely found together, our method provides very little added benefit over independent classifiers.  




§ ACKNOWLEDGEMENT


The support of the Office of Naval Research under grant N00014-20-1-2444, of USDA National Institute of Food and Agriculture under grant 2020-67021-32799/1024178 and Vizzhy.com are gratefully acknowledged.









 
  
  



















splncs04























