Skip to content

The PyTorch official implementation of the CVPR2021 Poster Paper NNM: Nearest Neighbor Matching for Deep Clustering.

License

Notifications You must be signed in to change notification settings

ZhiyuanDang/NNM

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NNM: Nearest Neighbor Matching for Deep Clustering.

Forked from SCAN (https://github.com/wvangansbeke/Unsupervised-Classification).

Introduction

The illustration of our idea. We propose to match more semantically nearest neighbors from between local (batch) and global (overall) level. Benefit from the dynamic updated deep features with iteration and epoch increases, we can construct more and more semantically confident sample pairs from samples and its neighbors.

Framework

Local Nearest Neighbor Matching

Global Nearest Neighbor Matching

For specifical loss, please refer paper and poster.

Main Results

Pre-Trained Models

Models Links
CIFAR-10 Google Drive
CIFAR-20 Google Drive
STL-10 Google Drive

Trained Models

Models ACC Links
CIFAR-10 0.8430 Google Drive
CIFAR-20 0.4773 Google Drive
STL-10 0.8084 Google Drive

Run

Requirements

Python 3.7 and Pytorch 1.4.0 are required. Please refer to requirements.yaml for more details.

Usages

Clone this repo: git clone https://github.com/ZhiyuanDang/NNM.git.

Download datasets: CIFAR-10/100, STL-10.

We can directly use the pre-text model from SCAN. Then, we only need to generate the neighbors by the code

python simclr.py --config_env configs/env.yml --config_exp configs/pretext/simclr_cifar10.yml.

Next, we run the clustering step (optional):

python scan.py --config_env configs/env.yml --config_exp configs/scan/scan_cifar10.yml --gpus 0 (--seed 1234).

Visualizing the top-k images is easily done by setting the --visualize_prototypes flag.

For example on cifar-10: python eval.py --config_exp configs/scan/scan_cifar10.yml --model $MODEL_PATH --visualize_prototypes.

And the Top-3 images is:

However, due to issues in SCAN, self-label is not suitable for NNM. Thus, we remove this file.

Citation

@InProceedings{Dang_2021_CVPR,
    author    = {Dang, Zhiyuan and Deng, Cheng and Yang, Xu and Wei, Kun and Huang, Heng},
    title     = {Nearest Neighbor Matching for Deep Clustering},
    booktitle = {Proceedings of the IEEE/CVF Conference on Computer Vision and Pattern Recognition (CVPR)},
    month     = {June},
    year      = {2021},
    pages     = {13693-13702}
}

Reference

SpCL (https://github.com/yxgeee/SpCL)

About

The PyTorch official implementation of the CVPR2021 Poster Paper NNM: Nearest Neighbor Matching for Deep Clustering.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages