{"id":21910491,"url":"https://github.com/chenshen03/deephash-tensorflow","last_synced_at":"2025-04-16T02:21:22.728Z","repository":{"id":165768750,"uuid":"187241546","full_name":"chenshen03/DeepHash-tensorflow","owner":"chenshen03","description":"DeepHash框架，包括DQN、DHN、DVSQ、DCH、DTQ等方法。","archived":false,"fork":false,"pushed_at":"2021-01-18T02:03:20.000Z","size":184,"stargazers_count":12,"open_issues_count":0,"forks_count":5,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-29T04:05:30.608Z","etag":null,"topics":["deephash","hash","tensorflow"],"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/chenshen03.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-05-17T15:36:01.000Z","updated_at":"2025-03-21T16:08:27.000Z","dependencies_parsed_at":"2023-07-06T08:32:08.955Z","dependency_job_id":null,"html_url":"https://github.com/chenshen03/DeepHash-tensorflow","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/chenshen03%2FDeepHash-tensorflow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenshen03%2FDeepHash-tensorflow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenshen03%2FDeepHash-tensorflow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chenshen03%2FDeepHash-tensorflow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chenshen03","download_url":"https://codeload.github.com/chenshen03/DeepHash-tensorflow/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249183804,"owners_count":21226261,"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":["deephash","hash","tensorflow"],"created_at":"2024-11-28T17:31:16.948Z","updated_at":"2025-04-16T02:21:22.721Z","avatar_url":"https://github.com/chenshen03.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeepHash-tensorflow\r\n\r\nThis code repository is derived from [thulab/DeepHash](https://github.com/thulab/DeepHash) but adds more features.\r\n\r\nSee the commits and update logs for details.\r\n\r\n## Update logs:\r\n- Metrics\r\n    - add WhRank\r\n    - add mAP_finetune\r\n    - add RAMAP\r\n- Backbone\r\n    - add VGG-F network\r\n- Loss functions\r\n    - add Independent loss\r\n    - add balance loss \r\n    - add orthogonal loss\r\n    - add exp loss\r\n    - add quantization losses, *i.e.*, L1 loss、L2 loss、cauchy loss\r\n- Tools\r\n    - add visualization tool such as T-SNE, *etc*\r\n    - add distance libs\r\n- Others\r\n    - refactoring the `data_provider` code\r\n    - refactoring the `model` code\r\n    - refactoring `parser`  code\r\n    - training acceleration\r\n\r\n## Contacts\r\nMaintainers of this library:\r\n* Shen Chen, Email: chenshen@stu.xmu.edu.cn\r\n\r\n---\r\nDeepHash is a lightweight deep learning to hash library that implements state-of-the-art deep hashing/quantization algorithms. We will implement more representative deep hashing models continuously according to our released [deep hashing paper list](https://github.com/caoyue10/DeepHashingBaselines). Specifically, we welcome other researchers to contribute deep hashing models into this toolkit based on our framework. We will announce the contribution in this project.\r\n\r\nThe implemented models include: \r\n\r\n* DQN: [Deep Quantization Network for Efficient Image Retrieval](http://yue-cao.me/doc/deep-quantization-networks-dqn-aaai16.pdf), Yue Cao, Mingsheng Long, Jianmin Wang, Han Zhu, Qingfu Wen, AAAI Conference on Artificial Intelligence (AAAI), 2016\r\n* DHN: [Deep Hashing Network for Efficient Similarity Retrieval](http://ise.thss.tsinghua.edu.cn/~mlong/doc/deep-hashing-network-aaai16.pdf), Han Zhu, Mingsheng Long, Jianmin Wang, Yue Cao, AAAI Conference on Artificial Intelligence (AAAI), 2016\r\n* DVSQ: [Deep Visual-Semantic Quantization for Efficient Image Retrieval](http://yue-cao.me/doc/deep-visual-semantic-quantization-cvpr17.pdf), Yue Cao, Mingsheng Long, Jianmin Wang, Shichen Liu, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2017 \r\n* DCH: [Deep Cauchy Hashing for Hamming Space Retrieval](http://ise.thss.tsinghua.edu.cn/~mlong/doc/deep-cauchy-hashing-cvpr18.pdf), Yue Cao, Mingsheng Long, Bin Liu, Jianmin Wang, IEEE Conference on Computer Vision and Pattern Recognition (CVPR), 2018\r\n* DTQ: [Deep Triplet Quantization](ise.thss.tsinghua.edu.cn/~mlong/doc/deep-triplet-quantization-acmmm18.pdf), Bin Liu, Yue Cao, Mingsheng Long, Jianmin Wang, Jingdong Wang, ACM Multimedia (ACMMM), 2018\r\n\r\nNote: DTQ and DCH are updated while DQN, DHN, DVSQ maybe outdated, feel free to touch us if you have any questions. We  welcome others to contribute!\r\n\r\n## Requirements\r\n\r\n-  Python3: Anaconda is recommended because it already contains a lot of packages: \r\n```\r\nconda create -n DeepHash python=3.6 anaconda\r\nsource activate DeepHash\r\n```\r\n-  Other packages: \r\n```\r\nconda install -y tensorflow-gpu\r\nconda install -y -c conda-forge opencv\r\n```\r\n\r\nTo import the pakcages implemented in `./DeepHash`, we need to add the path of `./DeepHash` to environment variables as:\r\n\r\n```shell\r\nexport PYTHONPATH=/path/to/project/DeepHash/DeepHash:$PYTHONPATH\r\n```\r\n\r\n## Data Preparation\r\nIn `data/cifar10/train.txt`, we give an example to show how to prepare image training data. In `data/cifar10/test.txt` and `data/cifar10/database.txt`, the list of testing and database images could be processed during predicting procedure. If you want to add other datasets as the input, you need to prepare `train.txt`, `test.txt` and `database.txt` as CIFAR-10 dataset.\r\n\r\nWhat's more, We have put the whole cifar10 dataset including the images and data list in the [release page](https://github.com/thulab/DeepHash/releases/download/v0.1/cifar10.zip). You can directly download it and unzip to data/cifar10 folder.\r\n\r\nMake sure the tree of `/path/to/project/data/cifar10` looks like this:\r\n\r\n```\r\n.\r\n|-- database.txt\r\n|-- test\r\n|-- test.txt\r\n|-- train\r\n`-- train.txt\r\n```\r\n\r\nIf you need run on NUSWIDE_81 and COCO, we recommend you to follow https://github.com/thuml/HashNet/tree/master/pytorch#datasets to prepare NUSWIDE_81 and COCO images.\r\n\r\nFor *DVSQ* model, you also need the *word vector* of the semantic labels. Here we use word2vec model pretrained on GoogleNews Dataset (e.g. https://github.com/mmihaltz/word2vec-GoogleNews-vectors), to extract the word embeddings for the labels of images, e.g. dog, cat and so on.\r\n\r\n## Get Started\r\n\r\n### Pre-trained model\r\n\r\nYou should manually download the model file of the Imagenet pre-tained AlexNet from [here](https://github.com/thulab/DeepHash/releases/download/v0.1/reference_pretrain.npy.zip) or from release page and unzip it to `/path/to/project/DeepHash/architecture/pretrained_model`.\r\n\r\nMake sure the tree of `/path/to/project/DeepHash/architecture` looks like this:\r\n\r\n```\r\n├── __init__.py\r\n├── pretrained_model\r\n       └── reference_pretrain.npy\r\n```\r\n\r\n### Training and Testing\r\n\r\nThe example of `$method` (DCH and DTQ) can be run like:\r\n\r\n```shell\r\ncd example/$method/\r\npython train_val_script.py --gpus \"0,1\" --data-dir $PWD/../../data --\"other parameters descirbe in train_val_script.py\"\r\n```\r\n\r\nFor DVSQ, DQN and DHN, please refer to the `train_val.sh` and `train_val_script.py` in the examples folder.\r\n\r\n## Citations\r\nIf you find *DeepHash* is useful for your research, please consider citing the following papers:\r\n\r\n    @InProceedings{cite:AAAI16DQN,\r\n      Author = {Yue Cao and Mingsheng Long and Jianmin Wang and Han Zhu and Qingfu Wen},\r\n      Publisher = {AAAI},\r\n      Title = {Deep Quantization Network for Efficient Image Retrieval},\r\n      Year = {2016}\r\n    }\r\n    \r\n    @InProceedings{cite:AAAI16DHN,\r\n      Author = {Han Zhu and Mingsheng Long and Jianmin Wang and Yue Cao},\r\n      Publisher = {AAAI},\r\n      Title = {Deep Hashing Network for Efficient Similarity Retrieval},\r\n      Year = {2016}\r\n    }\r\n    \r\n    @InProceedings{cite:CVPR17DVSQ,\r\n      Title={Deep visual-semantic quantization for efficient image retrieval},\r\n      Author={Cao, Yue and Long, Mingsheng and Wang, Jianmin and Liu, Shichen},\r\n      Booktitle={CVPR},\r\n      Year={2017}\r\n    }\r\n    \r\n    @InProceedings{cite:CVPR18DCH,\r\n      Title={Deep Cauchy Hashing for Hamming Space Retrieval},\r\n      Author={Cao, Yue and Long, Mingsheng and Bin, Liu and Wang, Jianmin},\r\n      Booktitle={CVPR},\r\n      Year={2018}\r\n    }\r\n    \r\n    @article{liu2018deep,\r\n      title={Deep triplet quantization},\r\n      author={Liu, Bin and Cao, Yue and Long, Mingsheng and Wang, Jianmin and Wang, Jingdong},\r\n      journal={MM, ACM},\r\n      year={2018}\r\n    }\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenshen03%2Fdeephash-tensorflow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchenshen03%2Fdeephash-tensorflow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchenshen03%2Fdeephash-tensorflow/lists"}