Code Monkey home page Code Monkey logo

kmeans_selfsuper's Introduction

Self-Supervised Learning for Large-Scale Unsupervised Image Clustering

PWC

This is code to run experiments for paper "Self-Supervised Learning for Large-Scale Unsupervised Image Clustering".

Running the code

For part of the models, you'll need to download the chekpoints manually:

and put them in chekpoint folder.

For SimCLRv2, BigBiGAN as well as supervised models checkpoints are downloaded automatically.

Download the code and install dependencies

Remember to clone the submodules by running

git clone --recurse-submodules https://github.com/Randl/kmeans_selfsuper.git

during cloning the repo, or, if you forgot to do it, by running

git submodule update --init --recursive

in the repo folder.

You'll need to install dependencies, by running

pip install -r requirements.txt

Generating features

For SimCLRv2 and BigBiGAN run

python3 generate_prediction_tf.py --model resnet152_simclr2
python3 generate_prediction_tf.py --model resnet50_simclr2
python3 generate_prediction_tf.py --model resnet152x3_simclr2
python3 generate_prediction_tf.py --model resnet50_bigbigan
python3 generate_prediction_tf.py --model revnet50x4_bigbigan

For InfoMin, MoCo v2 and SwAV, run

python3 generate_prediction_pytorch.py --model resnext152_infomin
python3 generate_prediction_pytorch.py --model resnet50_infomin
python3 generate_prediction_pytorch.py --model resnet50_mocov2
python3 generate_prediction_pytorch.py --model resnet50_swav

Finally, for supervised models, run

python3 generate_prediction_pytorch_supervised.py --model tf_efficientnet_l2_ns_475
python3 generate_prediction_pytorch_supervised.py --model gluon_resnet152_v1s
python3 generate_prediction_pytorch_supervised.py --model ig_resnext101_32x48d

You'll need large amount of RAM since the script keeps features in memory. It was tested on machine with 128 GB RAM.

Running clustering

To run clustering, you need to run

python3 cluster.py --model resnet50_infomin

where the model name should fit the name in generating part. For overclustering, e.g., 1.25 times more clusters than classes, run

python3 cluster.py --model resnet152_simclr2 --over 1.25

For using smaller dimensions of features, e.g., 512, run

python3 cluster.py --model resnet152_simclr2 --n-components 512

Citing the paper

If you found the paper or the code useful, please cite it. You can use following bibtex entry:

@article{zheltonozhskii2020unsupevised,
  title={Self-Supervised Learning for Large-Scale Unsupervised Image Clustering},
  author={Zheltonozhskii, Evgenii and Baskin, Chaim and Bronstein, Alex M. and Mendelson, Avi},
  journal={arXiv preprint arXiv:2008.10312},
  year={2020},
  url = {https://arxiv.org/abs/2008.10312}
}

kmeans_selfsuper's People

Contributors

randl avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.