{"id":13738082,"url":"https://github.com/ljin0429/HIST","last_synced_at":"2025-05-08T15:32:23.874Z","repository":{"id":38249805,"uuid":"469544690","full_name":"ljin0429/HIST","owner":"ljin0429","description":"Hypergraph-Induced Semantic Tuplet Loss for Deep Metric Learning [CVPR'22]","archived":false,"fork":false,"pushed_at":"2022-04-27T15:41:16.000Z","size":30,"stargazers_count":22,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-11-15T06:33:18.648Z","etag":null,"topics":["cvpr2022","deep-learning","graph-neural-networks","metric-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ljin0429.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2022-03-14T01:43:18.000Z","updated_at":"2024-11-06T14:08:42.000Z","dependencies_parsed_at":"2022-09-08T11:32:05.496Z","dependency_job_id":null,"html_url":"https://github.com/ljin0429/HIST","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljin0429%2FHIST","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljin0429%2FHIST/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljin0429%2FHIST/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ljin0429%2FHIST/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ljin0429","download_url":"https://codeload.github.com/ljin0429/HIST/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253096365,"owners_count":21853591,"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":["cvpr2022","deep-learning","graph-neural-networks","metric-learning","pytorch"],"created_at":"2024-08-03T03:02:10.691Z","updated_at":"2025-05-08T15:32:20.705Z","avatar_url":"https://github.com/ljin0429.png","language":"Python","funding_links":[],"categories":["Python","Papers"],"sub_categories":["2022"],"readme":"# Hypergraph-Induced Semantic Tuplet Loss for Deep Metric Learning (CVPR 2022)\nOfficial PyTorch implementation of **HIST loss** for deep metric learning | paper (The paper link will be updated soon!)\n\nThis repository provides \u003csup\u003e1)\u003c/sup\u003e source codes for the main results and \u003csup\u003e2)\u003c/sup\u003e pre-trained models for quick evaluation.\n\n## Requirements\n* Python3\n* PyTorch\n* [PyTorch Metric Learning](https://github.com/KevinMusgrave/pytorch-metric-learning)\n* Numpy\n* tqdm\n* pandas\n* matplotlib\n* wandb (optional)\n\n## Installation\nWe recommend using Conda (or Virtualenv) to set up an environment.\n\nOur implementation was tested on the following libraries with Python 3.6.\n\n* Install PyTorch:\n```\npip install torch==1.7.1+cu101 torchvision==0.8.2+cu101 torchaudio==0.7.2 -f https://download.pytorch.org/whl/torch_stable.html\n```\n\n* Install the other dependencies:\n```\npip install tqdm\npip install pandas\npip install matplotlib\npip install pytorch-metric-learning\npip install wandb\n```\n\n## Dataset preparation\nDownload three public benchmarks for deep metric learning, and extract the tgz or zip files into `./data/`.\n* [CUB-200-2011](http://www.vision.caltech.edu/datasets/cub_200_2011/)\n* [Cars-196](http://ai.stanford.edu/~jkrause/cars/car_dataset.html) \n* [Stanford Online Products](https://cvgl.stanford.edu/projects/lifted_struct/)\n\n**(Note)** For Cars-196, download both a tar of all images and annotations for both training and test images from the website, and then, put the files into `./data/cars196`.\n\n## Training\nOur HIST loss utilizes multilateral semantic relations between every sample and class for a given mini-batch via hypergraph modeling\n(see `./code/hist.py`).\nBy leveraging multilateral semantic relations, HIST loss enables the embedding network to capture important visual semantics suitable for deep metric learning.\nA standard embedding network (*e.g.*, ResNet-50) trained with our HIST loss (see `./code/train.py`) achieves SOTA performance on three public benckmarks for deep metric learning.\n\n### CUB-200-2011\n* Train an embedding network of ResNet-50 (D=512) using HIST loss:\n```bash\npython train.py --gpu-id 0\n                --dataset cub\n                --model resnet50\n                --embedding-size 512\n                --tau 32\n                --alpha 1.1\n                --epochs 40\n                --lr 1.2e-4\n                --lr-ds 1e-1\n                --lr-hgnn-factor 5\n                --weight-decay 5e-5\n                --lr-decay-step 5\n```\n\n### Cars-196\n* Train an embedding network of ResNet-50 (D=512) using HIST loss:\n```bash\npython train.py --gpu-id 0\n                --dataset cars\n                --model resnet50\n                --embedding-size 512\n                --tau 32\n                --alpha 0.9\n                --epochs 50\n                --lr 1e-4\n                --lr-ds 1e-1\n                --lr-hgnn-factor 10\n                --weight-decay 1e-4\n                --lr-decay-step 10\n```\n\n### Stanford Online Products\n* Train an embedding network of ResNet-50 (D=512) using HIST loss:\n```bash\npython train.py --gpu-id 0\n                --dataset SOP\n                --model resnet50\n                --embedding-size 512\n                --tau 16\n                --alpha 2\n                --epochs 60\n                --lr 1e-4\n                --lr-ds 1e-2\n                --lr-hgnn-factor 10\n                --weight-decay 1e-4\n                --lr-decay-step 10\n                --bn-freeze 0\n```\n\n## Evaluation\nFor an evaluation demo, we provide our pre-trained ResNet-50 (D=512) using HIST loss.\n\n* Download our torch models as follows:\n```bash\n# CUB-200-2011\nwget https://github.com/ljin0429/HIST/releases/download/torchmodel/cub_resnet50_best.pth\n# Cars-196\nwget https://github.com/ljin0429/HIST/releases/download/torchmodel/cars_resnet50_best.pth\n# Standord Online Products\nwget https://github.com/ljin0429/HIST/releases/download/torchmodel/SOP_resnet50_best.pth\n```\n\n* Evaluate the provided pre-trained model or your own trained model:\n```bash\n# The parameters should be changed according to the model to be evaluated.\npython evaluate.py --gpu-id 0 \n                   --dataset (cub/cars/SOP) \n                   --model resnet50 \n                   --model-path (your_model_path)\n```\n\n## Acknowledgements\nOur code was implemented, built upon the following great repositories:\n\n* [Proxy Anchor Loss for Deep Metric Learning](https://github.com/tjddus9597/Proxy-Anchor-CVPR2020) (CVPR 2020)\n* [Hypergraph Neural Networks](https://github.com/iMoonLab/HGNN) (AAAI 2019)\n* [PyTorch Metric Learning](https://github.com/KevinMusgrave/pytorch-metric-learning)\n\n## Citation\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljin0429%2FHIST","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fljin0429%2FHIST","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fljin0429%2FHIST/lists"}