Forked from SCAN (https://github.com/wvangansbeke/Unsupervised-Classification).
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.
Local Nearest Neighbor Matching
Global Nearest Neighbor Matching
For specifical loss, please refer paper and poster.
Models | Links |
---|---|
CIFAR-10 | Google Drive |
CIFAR-20 | Google Drive |
STL-10 | Google Drive |
Models | ACC | Links |
---|---|---|
CIFAR-10 | 0.8430 | Google Drive |
CIFAR-20 | 0.4773 | Google Drive |
STL-10 | 0.8084 | Google Drive |
Python 3.7 and Pytorch 1.4.0 are required. Please refer to requirements.yaml for more details.
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
.
However, due to issues in SCAN, self-label is not suitable for NNM. Thus, we remove this file.
@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}
}