Skip to content
wang22tiPublic

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

TKPR: Top-K Pairwise Ranking

License: MIT Python 3.7+ PyTorch arXiv

Official PyTorch implementation of "Top-K Pairwise Ranking: Bridging the Gap Among Ranking-Based Measures for Multi-Label Classification".

📋 Overview

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.

🚀 Quick Start

Dataset Preparation

  1. PASCAL VOC 2007/2012

    • Download from PASCAL VOC
    • Place in /path/to/datasets/VOC2007 and /path/to/datasets/VOC2012
  2. MS-COCO 2014

    • Download from MS-COCO
    • Place in /path/to/datasets/COCO
  3. NUS-WIDE

    • Download from NUS-WIDE
    • Place in /path/to/datasets/NUSWIDE

Training

Train with TKPR Loss

# 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 Baseline Losses

# 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

Using Shell Scripts

# Run predefined experiments
bash scripts/VOC_1_resnet50.sh

Validation

python validate.py \
    --dataset VOC2007 \
    --data /path/to/datasets \
    --model-name resnet50 \
    --num-classes 20 \
    --resume-path /path/to/checkpoint.ckpt \
    --batch-size 32

📊 Key Arguments

Common Arguments

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

📈 Results

Our method achieves state-of-the-art performance on multiple benchmarks. Below are the results from our paper.

MS-COCO (ResNet101, tab.5)

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

PASCAL VOC 2007 (ResNet101, tab.10)

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

NUS-WIDE (Swin-Transformer, tab.12)

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)

📝 Citation

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}
}

🙏 Acknowledgments

This codebase is built upon several excellent open-source projects: ASL, SPLC

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages