{"id":13737993,"url":"https://github.com/zbr17/AVSL","last_synced_at":"2025-05-08T15:32:10.712Z","repository":{"id":134694481,"uuid":"472793492","full_name":"zbr17/AVSL","owner":"zbr17","description":"[CVPR 2022] Official PyTorch implementation for Attributable Visual Similarity Learning ","archived":false,"fork":false,"pushed_at":"2022-10-17T08:46:49.000Z","size":412,"stargazers_count":33,"open_issues_count":1,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-11-15T06:33:02.403Z","etag":null,"topics":["explainability","metric-learning","similarity-learning"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zbr17.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,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-03-22T14:02:11.000Z","updated_at":"2024-07-07T02:30:18.000Z","dependencies_parsed_at":null,"dependency_job_id":"2c28b02c-59ec-4233-a9b2-1621acdf4f34","html_url":"https://github.com/zbr17/AVSL","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/zbr17%2FAVSL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbr17%2FAVSL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbr17%2FAVSL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zbr17%2FAVSL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zbr17","download_url":"https://codeload.github.com/zbr17/AVSL/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253096298,"owners_count":21853572,"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":["explainability","metric-learning","similarity-learning"],"created_at":"2024-08-03T03:02:08.444Z","updated_at":"2025-05-08T15:32:09.824Z","avatar_url":"https://github.com/zbr17.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Attributable Visual Similarity Learning\r\n\r\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/attributable-visual-similarity-learning/metric-learning-on-cars196)](https://paperswithcode.com/sota/metric-learning-on-cars196?p=attributable-visual-similarity-learning)\r\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/attributable-visual-similarity-learning/metric-learning-on-cub-200-2011)](https://paperswithcode.com/sota/metric-learning-on-cub-200-2011?p=attributable-visual-similarity-learning)\r\n[![PWC](https://img.shields.io/endpoint.svg?url=https://paperswithcode.com/badge/attributable-visual-similarity-learning/metric-learning-on-stanford-online-products-1)](https://paperswithcode.com/sota/metric-learning-on-stanford-online-products-1?p=attributable-visual-similarity-learning)\r\n\r\nThis repository is the official PyTorch implementation of **Attributable Visual Similarity Learning** (CVPR 2022). [![arXiv](https://img.shields.io/badge/arXiv-2203.14932-b31b1b.svg?style=flat)](https://arxiv.org/abs/2203.14932)\r\n\r\nThis paper proposes an attributable visual similarity learning (AVSL) framework for a more accurate and explainable similarity measure between images. \r\nExtensive experiments on the CUB-200-2011, Cars196, and Stanford Online Products datasets demonstrate significant improvements over existing deep similarity learning methods and verify the interpretability of our framework.\r\n\r\n## Framework\r\n\r\n![AEL](assets/framework.gif \"\u003cpicture name\u003e\")\r\n\r\n## Datasets \r\n\r\n### CUB-200-2011\r\n\r\nDownload from [here](http://www.vision.caltech.edu/visipedia/CUB-200-2011.html).\r\n\r\nOrganize the dataset as follows:\r\n\r\n```\r\n- cub200\r\n    |- train\r\n    |   |- class0\r\n    |   |   |- image0_1\r\n    |   |   |- ...\r\n    |   |- ...\r\n    |- test\r\n        |- class100\r\n        |   |- image100_1\r\n        |   |- ...\r\n        |- ...\r\n```\r\n\r\n### Cars196\r\n\r\nDownload from [here](http://ai.stanford.edu/~jkrause/cars/car_dataset.html).\r\n\r\nOrganize the dataset as follows:\r\n\r\n```\r\n- cars196\r\n    |- train\r\n    |   |- class0\r\n    |   |   |- image0_1\r\n    |   |   |- ...\r\n    |   |- ...\r\n    |- test\r\n        |- class98\r\n        |   |- image98_1\r\n        |   |- ...\r\n        |- ...\r\n```\r\n\r\n### Stanford Online Products\r\n\r\nDownload from [here](https://cvgl.stanford.edu/projects/lifted_struct/).\r\n\r\nOrganize the dataset as follows:\r\n\r\n```\r\n- online_products\r\n    |- images\r\n    |   |- bicycle_final \r\n    |   |- chair_final\r\n    |   |- ...\r\n    |- Info_Files\r\n        |- Ebay_final.txt\r\n        |- Ebay_info.txt\r\n        |- ...\r\n```\r\n\r\n## Requirements\r\n\r\nTo install requirements:\r\n\r\n```setup\r\npip install -r requirements.txt\r\n```\r\n\r\n## Training\r\n\r\n### Baseline models \r\n\r\nTo train `resnet50` on `Cars196` with `ProxyAnchor-baseline`, run this command as follows:\r\n\r\n```python\r\npython examples/demo.py --data_path \u003cpath-to-data\u003e --save_path \u003cpath-to-log\u003e --device 0 --batch_size 180 --test_batch_size 180 --setting proxy_anchor --embeddings_dim 512 --proxyanchor_margin 0.1 --proxyanchor_alpha 32 --num_classes 98 --wd 0.0001 --gamma 0.5 --step 10 --lr_trunk 0.0001 --lr_embedder 0.0001 --lr_collector 0.01 --dataset cars196 --model resnet50 --delete_old --save_name proxy-anchor-resnet50-cars196-baseline --warm_up 5 --warm_up_list embedder collector\r\n```\r\n\r\nFor more baseline settings, please refer to [`samples_baseline`](examples/samples_baseline.sh).\r\n\r\n### Our models\r\n\r\nTo train `resnet50` on `Cars196` with `ProxyAnchor-AVSL`, run this command as follows:\r\n\r\n```python\r\npython examples/demo.py --data_path \u003cpath-to-data\u003e --save_path \u003cpath-to-log\u003e --device 0 --batch_size 180 --test_batch_size 180 --setting avsl_proxyanchor --feature_dim_list 512 1024 2048 --embeddings_dim 512 --avsl_m 0.5 --topk_corr 128 --prob_gamma 10 --index_p 2 --pa_pos_margin 1.8 --pa_neg_margin 2.2 --pa_alpha 16 --final_pa_pos_margin 1.8 --final_pa_neg_margin 2.2 --final_pa_alpha 16 --num_classes 98 --use_proxy --wd 0.0001 --gamma 0.5 --step 5 --dataset cars196 --model resnet50 --splits_to_eval test --warm_up 5 --warm_up_list embedder collector --loss0_weight=1 --loss1_weight=4 --loss2_weight=4 --lr_collector=0.1 --lr_embedder=0.0002 --lr_trunk=0.0002 \\\r\n--save_name proxy-anchor-resnet50-cars196-avsl\r\n```\r\n\r\nFor more AVSL settings, please refer to [`samples_avsl`](examples/samples_avsl.sh).\r\n\r\n## Device \r\n\r\nWe tested our code on a linux machine with an Nvidia RTX 3090 GPU card. We recommend using a GPU card with a memory \u003e 16GB.\r\n\r\n## Results\r\n\r\nResults on CUB-200-2011:\r\n\r\n| Model name | Recall @ 1 | Recall @ 2 | Recall @ 4 | Recall @ 8 |\r\n| - | - | - | - | - |\r\n| baseline-PA | 69.7 | 80.0 | 87.0 | 92.4 |\r\n| AVSL-PA | 71.9 | 81.7 | 88.1 | 93.2 |\r\n\r\nResults on Cars196:\r\n\r\n| Model name | Recall @ 1 | Recall @ 2 | Recall @ 4 | Recall @ 8 |\r\n| - | - | - | - | - |\r\n| baseline-PA | 87.7 | 92.9 | 95.8 | 97.9 |\r\n| AVSL-PA | 91.5 | 95.0 | 97.0 | 98.4 |\r\n\r\nResults on Stanford Online Products:\r\n\r\n| Model name | Recall @ 1 | Recall @ 10 | Recall @ 100 |\r\n| - | - | - | - |\r\n| baseline-PA | 78.4 | 90.5 | 96.2 |\r\n| AVSL-PA | 79.6 | 91.4 | 96.4 |\r\n\r\n## Bibtex\r\n\r\n```\r\n@article{zhang2022attributable,\r\n  title={Attributable Visual Similarity Learning},\r\n  author={Borui Zhang and Wenzhao Zheng and Jie Zhou and Jiwen Lu},\r\n  journal={arXiv preprint arXiv:2203.14932},\r\n  year={2022}\r\n}\r\n```\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbr17%2FAVSL","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzbr17%2FAVSL","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzbr17%2FAVSL/lists"}