{"id":18317335,"url":"https://github.com/compvis/metric-learning-divide-and-conquer","last_synced_at":"2025-05-08T21:21:35.398Z","repository":{"id":65983453,"uuid":"173512545","full_name":"CompVis/metric-learning-divide-and-conquer","owner":"CompVis","description":"Source code for the paper \"Divide and Conquer the Embedding Space for Metric Learning\", CVPR 2019","archived":false,"fork":false,"pushed_at":"2019-10-24T18:27:47.000Z","size":34,"stargazers_count":264,"open_issues_count":6,"forks_count":44,"subscribers_count":21,"default_branch":"master","last_synced_at":"2025-03-31T18:21:20.477Z","etag":null,"topics":["few-shot-learning","metric-learning","pytorch"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/CompVis.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-03-03T00:05:50.000Z","updated_at":"2024-12-27T05:49:59.000Z","dependencies_parsed_at":"2023-02-19T19:00:48.654Z","dependency_job_id":null,"html_url":"https://github.com/CompVis/metric-learning-divide-and-conquer","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fmetric-learning-divide-and-conquer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fmetric-learning-divide-and-conquer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fmetric-learning-divide-and-conquer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/CompVis%2Fmetric-learning-divide-and-conquer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/CompVis","download_url":"https://codeload.github.com/CompVis/metric-learning-divide-and-conquer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253150083,"owners_count":21861831,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["few-shot-learning","metric-learning","pytorch"],"created_at":"2024-11-05T18:05:47.111Z","updated_at":"2025-05-08T21:21:35.380Z","avatar_url":"https://github.com/CompVis.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Divide and Conquer the Embedding Space for Metric Learning\n\n## About\n\nThis repository contains the code for reproducing the results for [Divide and Conquer the Embedding Space for Metric Learning](http://openaccess.thecvf.com/content_CVPR_2019/papers/Sanakoyeu_Divide_and_Conquer_the_Embedding_Space_for_Metric_Learning_CVPR_2019_paper.pdf) (CVPR 2019) with the datasets [In-Shop Clothes](http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion/InShopRetrieval.html), [Stanford Online Products](http://cvgl.stanford.edu/projects/lifted_struct/) and [PKU VehicleID](https://www.pkuml.org/resources/pku-vehicleid.html).\n\n**Paper**: [pdf](http://openaccess.thecvf.com/content_CVPR_2019/papers/Sanakoyeu_Divide_and_Conquer_the_Embedding_Space_for_Metric_Learning_CVPR_2019_paper.pdf)  \n**Supplementary**: [pdf](http://openaccess.thecvf.com/content_CVPR_2019/supplemental/Sanakoyeu_Divide_and_Conquer_CVPR_2019_supplemental.pdf)\n\nWe also applied our method to the [Humpback Whale Identification Challenge](https://www.kaggle.com/c/humpback-whale-identification/overview) at Kaggle and finished at 10th place out of 2131.  \n**Slides**: [link](https://slides.com/asanakoy/metric-learning-kaggle-whales)\n\n\u003cimg src=\"https://asanakoy.github.io/images/teaser_cvpr19_dml.jpg\" width=\"480\" alt=\"method pipeline\"\u003e\n\n## Requirements\n\n- Python version 3.6.6 or higher\n- SciPy and scikit-learn packages\n- PyTorch ([pytorch.org](http://pytorch.org))\n- Faiss with GPU support ([Faiss](https://github.com/facebookresearch/faiss))\n- download and extract the datasets for [In-Shop Clothes](http://mmlab.ie.cuhk.edu.hk/projects/DeepFashion/InShopRetrieval.html), [Stanford Online Products](http://cvgl.stanford.edu/projects/lifted_struct/) and [PKU VehicleID](https://www.pkuml.org/resources/pku-vehicleid.html)\n\n## Usage\n\nThe following command will train the model with Margin loss on the In-Shop Clothes dataset for 200 epochs and a batch size of 80 while splitting the embedding layer with 8 clusters and finetuning the model from epoch 190 on. You can use this command to reproduce the results of the paper for the three datasets by changing simply `--dataset=inshop` to `--dataset=sop` (Stanford Online Products) or `--dataset=vid` (Vehicle-ID).\n\n```\nCUDA_VISIBLE_DEVICES=0 python experiment.py --dataset=inshop \\\n--dir=test --exp=0 --random-seed=0 --nb-clusters=8 --nb-epochs=200 \\\n--sz-batch=80 --backend=faiss-gpu  --embedding-lr=1e-5 --embedding-wd=1e-4 \\\n--backbone-lr=1e-5 --backbone-wd=1e-4 --finetune-epoch=190\n```\n\nThe model can be trained without the proposed method by setting the number of clusters to 1 with `--nb-clusters=1`.  \nFor faster clustering we run Faiss on GPU. If you installed Faiss without GPU support use flag `--backend=faiss`.\n## Expected Results\n\nThe model checkpoints and log files are saved in the selected log-directory. You can print a summary of the results with `python browse_results \u003clog path\u003e`.\n\nYou will get slightly higher results than what we have reported in the paper. For SOP, In-Shop and Vehicle-ID the R@1 results should be somewhat around 76.40, 87.36 and 91.54.\n\n## Related Repos\n\n- Collection of baselines for metric learning from @Confusezius [[PyTorch](https://github.com/Confusezius/Deep-Metric-Learning-Baselines)]\n\n## License\n\nYou may find out more about the license [here](LICENSE)\n\n## Reference\n\nIf you use this code, please cite the following paper:\n\nArtsiom Sanakoyeu, Vadim Tschernezki, Uta Büchler, Björn Ommer. \"Divide and Conquer the Embedding Space for Metric Learning\", CVPR 2019.\n\n```\n@InProceedings{dcesml,\n  title={Divide and Conquer the Embedding Space for Metric Learning},\n  author={Sanakoyeu, Artsiom and Tschernezki, Vadim and B\\\"uchler, Uta and Ommer, Bj\\\"orn},\n  booktitle={Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition},\n  year={2019},\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompvis%2Fmetric-learning-divide-and-conquer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcompvis%2Fmetric-learning-divide-and-conquer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcompvis%2Fmetric-learning-divide-and-conquer/lists"}