Official PyTorch implementation of "Top-K Pairwise Ranking: Bridging the Gap Among Ranking-Based Measures for Multi-Label Classification".
This repository contains the implementation of Top-K Pairwise Ranking (TKPR), a novel loss function designed to bridge the gap among ranking-based measures for multi-label classification. TKPR optimizes for top-K ranking metrics and demonstrates superior performance on various multi-label learning benchmarks.
-
PASCAL VOC 2007/2012
- Download from PASCAL VOC
- Place in
/path/to/datasets/VOC2007and/path/to/datasets/VOC2012
-
MS-COCO 2014
- Download from MS-COCO
- Place in
/path/to/datasets/COCO
-
NUS-WIDE
- Download from NUS-WIDE
- Place in
/path/to/datasets/NUSWIDE
# PASCAL VOC with ResNet-50
python train.py \
--dataset VOC \
--data /path/to/datasets \
--model-name resnet50 \
--num-classes 20 \
--batch-size 64 \
--lr 1e-4 \
--criterion TKPR_loss \
--weight-scheme Naive \
--weight-type M \
--K 3 \
--optimizer Adam \
--epoch 80# Train with ranking loss
python train.py \
--dataset VOC \
--data /path/to/datasets \
--model-name resnet50 \
--num-classes 20 \
--batch-size 64 \
--lr 1e-4 \
--criterion ranking_loss \
--optimizer Adam \
--epoch 80
# Train with Hill loss
python train.py \
--dataset VOC \
--data /path/to/datasets \
--model-name resnet50 \
--num-classes 20 \
--batch-size 64 \
--lr 1e-4 \
--criterion Hill \
--optimizer Adam \
--epoch 80
# Train with SPLC loss
python train.py \
--dataset VOC \
--data /path/to/datasets \
--model-name resnet50 \
--num-classes 20 \
--batch-size 64 \
--lr 1e-4 \
--criterion SPLC \
--optimizer Adam \
--epoch 80# Run predefined experiments
bash scripts/VOC_1_resnet50.shpython validate.py \
--dataset VOC2007 \
--data /path/to/datasets \
--model-name resnet50 \
--num-classes 20 \
--resume-path /path/to/checkpoint.ckpt \
--batch-size 32| Argument | Default | Description |
|---|---|---|
--dataset |
VOC | Dataset name: VOC, COCO, NUS |
--data |
/home/datasets | Path to dataset directory |
--model-name |
resnet101 | Backbone: resnet50, resnet101, swin |
--num-classes |
20 | Number of classes |
--batch-size |
32 | Mini-batch size |
--lr |
1e-4 | Learning rate |
--epoch |
100 | Number of epochs |
--optimizer |
SGD | Optimizer: SGD or Adam |
--criterion |
ranking_loss | Loss function |
--missing |
0 | 0: full labels, 1: missing labels |
Our method achieves state-of-the-art performance on multiple benchmarks. Below are the results from our paper.
| Method | P@3 | P@5 | R@3 | R@5 | mAP@3 | mAP@5 | NDCG@3 | NDCG@5 | Ranking Loss |
|---|---|---|---|---|---|---|---|---|---|
| TKPR (Ours) | 0.587 | 0.432 | 0.724 | 0.832 | 0.752 | 0.758 | 0.813 | 0.831 | 0.024 |
| Method | P@3 | P@5 | R@3 | R@5 | mAP@3 | mAP@5 | NDCG@3 | NDCG@5 | Ranking Loss |
|---|---|---|---|---|---|---|---|---|---|
| TKPR (Ours) | 0.455 | 0.279 | 0.977 | 0.989 | 0.962 | 0.967 | 0.972 | 0.977 | 0.007 |
| Method | P@3 | P@5 | R@3 | R@5 | mAP@3 | mAP@5 | NDCG@3 | NDCG@5 | Ranking Loss |
|---|---|---|---|---|---|---|---|---|---|
| TKPR (Ours) | 0.581 | 0.425 | 0.809 | 0.916 | 0.827 | 0.840 | 0.864 | 0.885 | 0.0122 |
(Please refer to our paper for detailed experimental results and comparisons with other methods)
If you find this work useful in your research, please consider citing:
@article{wang2025tkpr,
title={Top-K Pairwise Ranking: Bridging the Gap Among Ranking-Based Measures for Multi-Label Classification},
author={Wang, Zitai and Xu, Qianqian and Yang, Zhiyong and Wen, Peisong and He, Yuan and Cao, Xiaochun and Huang, Qingming},
journal={International Journal of Computer Vision},
volume={133},
number={1},
pages={211--253},
year={2025}
}This codebase is built upon several excellent open-source projects: ASL, SPLC
This project is licensed under the MIT License - see the LICENSE file for details.