├── .gitignore ├── LICENSE ├── README.md ├── demo_picture ├── a.jpeg ├── aa.jpeg ├── b.jpeg └── bb.jpeg └── triplet-deep-hash-pytorch ├── data ├── test │ └── 1.jpg └── train │ ├── 1 │ └── 1.jpg │ ├── 2 │ └── 1.jpg │ ├── 3 │ └── 1.jpg │ └── 4 │ └── 1.jpg ├── feature ├── generated_dataset │ └── neg_fea.pt ├── test │ └── test.npy └── train │ └── 1.npy ├── model └── hashNetInceptionv4-epoch1.pth └── src ├── extract_feature ├── LICENSE ├── README.md ├── batch_extract_test.py ├── batch_extract_train.py ├── convert_weights │ ├── convert_dims.py │ ├── convert_kernels.py │ ├── convert_weights_to_keras.py │ ├── get_inception_weights.py │ ├── helper_net │ │ ├── __init__.py │ │ ├── inception_utils.py │ │ └── inception_v4.py │ └── inception_utils.py ├── evaluate_image.py ├── inception_v4.py └── validation_utils │ ├── GTL.txt │ ├── class_names.txt │ └── convert_ground_truth_labels │ ├── convert_ground_truth_labels.py │ ├── correct_classes.txt │ ├── old_classes_raw.txt │ └── val_ground_truth_labels.txt └── hash_net ├── generate_random_dataset.py └── hashNet.py /.gitignore: -------------------------------------------------------------------------------- 1 | # Byte-compiled / optimized / DLL files 2 | __pycache__/ 3 | *.py[cod] 4 | *$py.class 5 | 6 | # C extensions 7 | *.so 8 | 9 | # Distribution / packaging 10 | .Python 11 | env/ 12 | build/ 13 | develop-eggs/ 14 | dist/ 15 | downloads/ 16 | eggs/ 17 | .eggs/ 18 | lib/ 19 | lib64/ 20 | parts/ 21 | sdist/ 22 | var/ 23 | wheels/ 24 | *.egg-info/ 25 | .installed.cfg 26 | *.egg 27 | 28 | # PyInstaller 29 | # Usually these files are written by a python script from a template 30 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 31 | *.manifest 32 | *.spec 33 | 34 | # Installer logs 35 | pip-log.txt 36 | pip-delete-this-directory.txt 37 | 38 | # Unit test / coverage reports 39 | htmlcov/ 40 | .tox/ 41 | .coverage 42 | .coverage.* 43 | .cache 44 | nosetests.xml 45 | coverage.xml 46 | *.cover 47 | .hypothesis/ 48 | 49 | # Translations 50 | *.mo 51 | *.pot 52 | 53 | # Django stuff: 54 | *.log 55 | local_settings.py 56 | 57 | # Flask stuff: 58 | instance/ 59 | .webassets-cache 60 | 61 | # Scrapy stuff: 62 | .scrapy 63 | 64 | # Sphinx documentation 65 | docs/_build/ 66 | 67 | # PyBuilder 68 | target/ 69 | 70 | # Jupyter Notebook 71 | .ipynb_checkpoints 72 | 73 | # pyenv 74 | .python-version 75 | 76 | # celery beat schedule file 77 | celerybeat-schedule 78 | 79 | # SageMath parsed files 80 | *.sage.py 81 | 82 | # dotenv 83 | .env 84 | 85 | # virtualenv 86 | .venv 87 | venv/ 88 | ENV/ 89 | 90 | # Spyder project settings 91 | .spyderproject 92 | .spyproject 93 | 94 | # Rope project settings 95 | .ropeproject 96 | 97 | # mkdocs documentation 98 | /site 99 | 100 | # mypy 101 | .mypy_cache/ 102 | 103 | .DS_Store 104 | */.DS_Store 105 | .DS_Store 106 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Triplet-deep-hash-pytorch 2 | Pytorch implementation of "Fast Training of Triplet-based Deep Binary Embedding Networks". 3 | http://arxiv.org/abs/1603.02844 4 | 5 | Feel free to contribute code. 6 | 7 | # Update 2017.11.13 8 | Refactor this project. 9 | 10 | Use code in https://github.com/kentsommer/keras-inceptionV4 to extract feature. 11 | 12 | 13 | # DEMO 14 | Deep hash for "A", "B". 15 | ![](https://raw.githubusercontent.com/xwzy/triplet-deep-hash-pytorch/master/demo_picture/a.jpeg) 16 | ![](https://raw.githubusercontent.com/xwzy/triplet-deep-hash-pytorch/master/demo_picture/aa.jpeg) 17 | ![](https://raw.githubusercontent.com/xwzy/triplet-deep-hash-pytorch/master/demo_picture/b.jpeg) 18 | ![](https://raw.githubusercontent.com/xwzy/triplet-deep-hash-pytorch/master/demo_picture/bb.jpeg) 19 | 20 | # TODO 21 | - [x] Add multiclass support. 22 | - [x] Make code clean. 23 | - [ ] Add more base networks. 24 | - [ ] Add query code for new project. 25 | 26 | # Usage 27 | ## Train 28 | 1. Put training pictures in `train/[category-id]`, test pictures in `data/test`. 29 | 2. Run `src/extract_feature/batch_extarct_test.py` and `src/extract_feature/batch_extract_train.py` to extract feature for future use. 30 | 3. Run `src/hash_net/generate_random_dataset.py` to generate random training data. 31 | 4. Run `src/hash_net/hashNet.py` to train your triplet deep hash network. 32 | 33 | 34 | ~~## Test~~ 35 | 36 | ~~1. Create folder *test*, and create *pos*, *neg* in *test* with pictures that you want to retrive.~~ 37 | 38 | ~~2. Run `testQue.py` to query your picture set.~~ 39 | -------------------------------------------------------------------------------- /demo_picture/a.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xwzy/Triplet-deep-hash-pytorch/1bc58c6381e815ee3656b17892635acfb95d38bc/demo_picture/a.jpeg -------------------------------------------------------------------------------- /demo_picture/aa.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xwzy/Triplet-deep-hash-pytorch/1bc58c6381e815ee3656b17892635acfb95d38bc/demo_picture/aa.jpeg -------------------------------------------------------------------------------- /demo_picture/b.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xwzy/Triplet-deep-hash-pytorch/1bc58c6381e815ee3656b17892635acfb95d38bc/demo_picture/b.jpeg -------------------------------------------------------------------------------- /demo_picture/bb.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xwzy/Triplet-deep-hash-pytorch/1bc58c6381e815ee3656b17892635acfb95d38bc/demo_picture/bb.jpeg -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/data/test/1.jpg: -------------------------------------------------------------------------------- 1 | 123 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/data/train/1/1.jpg: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/data/train/2/1.jpg: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/data/train/3/1.jpg: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/data/train/4/1.jpg: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/feature/generated_dataset/neg_fea.pt: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/feature/test/test.npy: -------------------------------------------------------------------------------- 1 | test 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/feature/train/1.npy: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/model/hashNetInceptionv4-epoch1.pth: -------------------------------------------------------------------------------- 1 | 1 2 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/README.md: -------------------------------------------------------------------------------- 1 | # Keras Inception-V4 2 | Keras implementation of Google's inception v4 model with ported weights! 3 | 4 | As described in: 5 | [Inception-v4, Inception-ResNet and the Impact of Residual Connections on Learning (Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi)](https://arxiv.org/abs/1602.07261) 6 | 7 | Note this Keras implementation tries to follow the [tf.slim definition](https://github.com/tensorflow/models/blob/master/slim/nets/inception_v4.py) as closely as possible. 8 | 9 | Pre-Trained weights for this Keras model can be found here (ported from the tf.slim ckpt): https://github.com/kentsommer/keras-inceptionV4/releases 10 | 11 | You can evaluate a sample image by performing the following (weights are downloaded automatically): 12 | * ```$ python evaluate_image.py``` 13 | ``` 14 | Loaded Model Weights! 15 | Class is: African elephant, Loxodonta africana 16 | Certainty is: 0.868498 17 | ``` 18 | 19 | # News 20 | 5/23/2017: 21 | 22 | * Enabled support for both Theano and Tensorflow (again... :neckbeard:) 23 | * Added useful training parameters 24 | * l2 regularization added to conv layers 25 | * Variance Scaling initialization added to conv layers 26 | * Momentum value updated for batch_norm layers 27 | * Updated pre-processing to match paper (subtracts 0.5 instead of 1.0 :fire:) 28 | * Minor code changes and cleanup is also included in the recent changes 29 | 30 | 31 | 32 | 33 | # Performance Metrics (@Top5, @Top1) 34 | 35 | Error rate on non-blacklisted subset of ILSVRC2012 Validation Dataset (Single Crop): 36 | * Top@1 Error: 19.54% 37 | * Top@5 Error: 4.88% 38 | 39 | These error rates are actually slightly lower than the listed error rates in the paper: 40 | * Top@1 Error: 20.0% 41 | * Top@5 Error: 5.0% 42 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/batch_extract_test.py: -------------------------------------------------------------------------------- 1 | from keras import backend as K 2 | import inception_v4 3 | import numpy as np 4 | import cv2 5 | import os 6 | import skimage.measure 7 | from tqdm import tqdm 8 | 9 | # This function comes from Google's ImageNet Preprocessing Script 10 | def central_crop(image, central_fraction): 11 | """Crop the central region of the image. 12 | Remove the outer parts of an image but retain the central region of the image 13 | along each dimension. If we specify central_fraction = 0.5, this function 14 | returns the region marked with "X" in the below diagram. 15 | -------- 16 | | | 17 | | XXXX | 18 | | XXXX | 19 | | | where "X" is the central 50% of the image. 20 | -------- 21 | Args: 22 | image: 3-D array of shape [height, width, depth] 23 | central_fraction: float (0, 1], fraction of size to crop 24 | Raises: 25 | ValueError: if central_crop_fraction is not within (0, 1]. 26 | Returns: 27 | 3-D array 28 | """ 29 | if central_fraction <= 0.0 or central_fraction > 1.0: 30 | raise ValueError('central_fraction must be within (0, 1]') 31 | if central_fraction == 1.0: 32 | return image 33 | 34 | img_shape = image.shape 35 | depth = img_shape[2] 36 | fraction_offset = int(1 / ((1 - central_fraction) / 2.0)) 37 | bbox_h_start = int(np.divide(img_shape[0], fraction_offset)) 38 | bbox_w_start = int(np.divide(img_shape[1], fraction_offset)) 39 | 40 | bbox_h_size = int(img_shape[0] - bbox_h_start * 2) 41 | bbox_w_size = int(img_shape[1] - bbox_w_start * 2) 42 | 43 | image = image[bbox_h_start:bbox_h_start + bbox_h_size, bbox_w_start:bbox_w_start + bbox_w_size] 44 | return image 45 | 46 | 47 | def get_processed_image(img_path): 48 | # Load image and convert from BGR to RGB 49 | im = np.asarray(cv2.imread(img_path))[:, :, ::-1] 50 | im = central_crop(im, 0.875) 51 | im = cv2.resize(im, (299, 299)) 52 | im = inception_v4.preprocess_input(im) 53 | if K.image_data_format() == "channels_first": 54 | im = np.transpose(im, (2, 0, 1)) 55 | im = im.reshape(-1, 3, 299, 299) 56 | else: 57 | im = im.reshape(-1, 299, 299, 3) 58 | return im 59 | 60 | 61 | def poolingPreds(preds): 62 | preds = preds.reshape(8, 8, -1) 63 | res = skimage.measure.block_reduce(preds, (8, 8, 1), np.max) 64 | return res.reshape(-1) 65 | 66 | 67 | def predict(model, path): 68 | img = get_processed_image(path) 69 | preds = model.predict(img) 70 | return preds 71 | 72 | 73 | if __name__ == "__main__": 74 | model = inception_v4.create_model(weights='imagenet', include_top=False) 75 | 76 | basePath = '../../data/test/' 77 | imageName = os.listdir(basePath) 78 | feature_list = np.array([[]]) 79 | for ii in tqdm(range(len(imageName))): 80 | i = imageName[ii] 81 | if i.startswith('.'): 82 | continue 83 | f = poolingPreds(predict(model, os.path.join(basePath, i))) 84 | if feature_list.size == 0: 85 | feature_list = np.array([f]) 86 | else: 87 | feature_list = np.concatenate((feature_list, np.array([f])), axis=0) 88 | np.save('../../feature/test/test.npy', feature_list) 89 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/batch_extract_train.py: -------------------------------------------------------------------------------- 1 | from keras import backend as K 2 | import inception_v4 3 | import numpy as np 4 | import cv2 5 | import os 6 | import skimage.measure 7 | from tqdm import tqdm 8 | 9 | # This function comes from Google's ImageNet Preprocessing Script 10 | def central_crop(image, central_fraction): 11 | """Crop the central region of the image. 12 | Remove the outer parts of an image but retain the central region of the image 13 | along each dimension. If we specify central_fraction = 0.5, this function 14 | returns the region marked with "X" in the below diagram. 15 | -------- 16 | | | 17 | | XXXX | 18 | | XXXX | 19 | | | where "X" is the central 50% of the image. 20 | -------- 21 | Args: 22 | image: 3-D array of shape [height, width, depth] 23 | central_fraction: float (0, 1], fraction of size to crop 24 | Raises: 25 | ValueError: if central_crop_fraction is not within (0, 1]. 26 | Returns: 27 | 3-D array 28 | """ 29 | if central_fraction <= 0.0 or central_fraction > 1.0: 30 | raise ValueError('central_fraction must be within (0, 1]') 31 | if central_fraction == 1.0: 32 | return image 33 | 34 | img_shape = image.shape 35 | depth = img_shape[2] 36 | fraction_offset = int(1 / ((1 - central_fraction) / 2.0)) 37 | bbox_h_start = int(np.divide(img_shape[0], fraction_offset)) 38 | bbox_w_start = int(np.divide(img_shape[1], fraction_offset)) 39 | 40 | bbox_h_size = int(img_shape[0] - bbox_h_start * 2) 41 | bbox_w_size = int(img_shape[1] - bbox_w_start * 2) 42 | 43 | image = image[bbox_h_start:bbox_h_start + bbox_h_size, bbox_w_start:bbox_w_start + bbox_w_size] 44 | return image 45 | 46 | 47 | def get_processed_image(img_path): 48 | # Load image and convert from BGR to RGB 49 | im = np.asarray(cv2.imread(img_path))[:, :, ::-1] 50 | im = central_crop(im, 0.875) 51 | im = cv2.resize(im, (299, 299)) 52 | im = inception_v4.preprocess_input(im) 53 | if K.image_data_format() == "channels_first": 54 | im = np.transpose(im, (2, 0, 1)) 55 | im = im.reshape(-1, 3, 299, 299) 56 | else: 57 | im = im.reshape(-1, 299, 299, 3) 58 | return im 59 | 60 | 61 | def poolingPreds(preds): 62 | preds = preds.reshape(8, 8, -1) 63 | res = skimage.measure.block_reduce(preds, (8, 8, 1), np.max) 64 | return res.reshape(-1) 65 | 66 | 67 | def predict(model, path): 68 | img = get_processed_image(path) 69 | preds = model.predict(img) 70 | return preds 71 | 72 | 73 | if __name__ == "__main__": 74 | model = inception_v4.create_model(weights='imagenet', include_top=False) 75 | 76 | for c in tqdm(range(1, 31)): 77 | basePath = '../../data/train/' + str(c) 78 | imageName = os.listdir(basePath) 79 | feature_list = np.array([[]]) 80 | for i in imageName: 81 | if i.startswith('.'): 82 | continue 83 | f = poolingPreds(predict(model, os.path.join(basePath, i))) 84 | if feature_list.size == 0: 85 | feature_list = np.array([f]) 86 | else: 87 | feature_list = np.concatenate((feature_list, np.array([f])), axis=0) 88 | np.save('../../feature/train/'+str(c)+'.npy', feature_list) 89 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/convert_dims.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.insert(0,'..') 3 | 4 | from keras import backend as K 5 | from keras.utils.layer_utils import convert_all_kernels_in_model 6 | import inception_v4 7 | import numpy as np 8 | import itertools 9 | import pickle 10 | import os 11 | import re 12 | 13 | def shuffle_rows(original_w): 14 | converted_w = np.zeros(original_w.shape) 15 | count = 0 16 | for index, row in enumerate(original_w): 17 | if (index % 256) == 0 and index != 0: 18 | count += 1 19 | new_index = ((index % 256) * 6) + count 20 | print("index from " + str(index) + " -> " + str(new_index)) 21 | converted_w[new_index] = row 22 | initial = 1 23 | return converted_w 24 | 25 | def atoi(text): 26 | return int(text) if text.isdigit() else text 27 | 28 | def natural_keys(myobject): 29 | return [ atoi(c) for c in re.split('(\d+)', myobject.name) ] 30 | 31 | def get_layers(model): 32 | # Get Trainable layers 33 | layers = model.layers 34 | layers.sort(key=natural_keys) 35 | result = [] 36 | for i in range(len(layers)): 37 | try: 38 | layer = model.layers[i] 39 | if layer.trainable: 40 | bad = ["pooling", "flatten", "dropout", "activation", "concatenate"] 41 | if not any(word in layer.name for word in bad): 42 | result.append(layer) 43 | except: 44 | continue 45 | bn,cv,fn=result[:int((len(result)-1)/2)],result[int((len(result)-1)/2):],result[-1] 46 | res_zipped = zip(cv, bn) 47 | out_prep = [list(elem) for elem in res_zipped] 48 | out = out_prep + [[fn]] 49 | return out 50 | 51 | 52 | K.set_image_dim_ordering('th') 53 | 54 | th_model = inception_v4.create_model() 55 | 56 | th_layers = get_layers(th_model) 57 | th_layers = list(itertools.chain.from_iterable(th_layers)) 58 | 59 | conv_classes = { 60 | 'Convolution1D', 61 | 'Convolution2D', 62 | 'Convolution3D', 63 | 'AtrousConvolution2D', 64 | 'Deconvolution2D', 65 | } 66 | 67 | weights_list = pickle.load( open( "weights_tf_dim_ordering_th_kernels.p", "rb" ) ) 68 | 69 | for index, th_layer in enumerate(th_layers): 70 | if th_layer.__class__.__name__ in conv_classes: 71 | weights = weights_list[index] 72 | weights[0] = weights[0].transpose((3,2,0,1)) 73 | th_layer.set_weights(weights) 74 | print('converted ', th_layer.name) 75 | # elif th_layer.__class__.__name__ == "Dense": 76 | # weights = weights_list[index] 77 | # weights[0] = shuffle_rows(weights[0]) 78 | # th_layer.set_weights(weights) 79 | # print('converted ', th_layer.name) 80 | # elif th_layer.__class__.__name__ not in bad_classes: 81 | else: 82 | th_layer.set_weights(weights_list[index]) 83 | print('Set: ', th_layer.name) 84 | 85 | 86 | th_model.save_weights('../weights/inception-v4_weights_th_dim_ordering_th_kernels.h5') 87 | 88 | 89 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/convert_kernels.py: -------------------------------------------------------------------------------- 1 | import sys 2 | sys.path.insert(0,'..') 3 | 4 | from keras import backend as K 5 | from keras.utils.layer_utils import convert_all_kernels_in_model 6 | import inception_v4 7 | import numpy as np 8 | import itertools 9 | import pickle 10 | import re 11 | 12 | def atoi(text): 13 | return int(text) if text.isdigit() else text 14 | 15 | def natural_keys(myobject): 16 | return [ atoi(c) for c in re.split('(\d+)', myobject.name) ] 17 | 18 | def get_layers(model): 19 | # Get Trainable layers 20 | layers = model.layers 21 | layers.sort(key=natural_keys) 22 | result = [] 23 | for i in range(len(layers)): 24 | try: 25 | layer = model.layers[i] 26 | if layer.trainable: 27 | bad = ["pooling", "flatten", "dropout", "activation", "concatenate"] 28 | if not any(word in layer.name for word in bad): 29 | result.append(layer) 30 | except: 31 | continue 32 | bn,cv,fn=result[:int((len(result)-1)/2)],result[int((len(result)-1)/2):],result[-1] 33 | res_zipped = zip(cv, bn) 34 | out_prep = [list(elem) for elem in res_zipped] 35 | out = out_prep + [[fn]] 36 | return out 37 | 38 | K.set_image_dim_ordering('tf') 39 | 40 | th_model = inception_v4.create_model(weights="../weights/inception-v4_weights_tf_dim_ordering_tf_kernels.h5") 41 | 42 | convert_all_kernels_in_model(th_model) 43 | print("Converted all Kernels") 44 | 45 | th_layers = get_layers(th_model) 46 | th_layers = list(itertools.chain.from_iterable(th_layers)) 47 | 48 | weights = [] 49 | for th_layer in th_layers: 50 | weights.append(th_layer.get_weights()) 51 | print("Saving layer: " + th_layer.name) 52 | 53 | pickle.dump(weights, open( "weights_tf_dim_ordering_th_kernels.p", "wb" ) ) 54 | print("Saved Pickle of Weights") 55 | 56 | 57 | 58 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/convert_weights_to_keras.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import 2 | from __future__ import division 3 | from __future__ import print_function 4 | 5 | import sys 6 | sys.path.insert(0,'..') 7 | 8 | import tensorflow as tf 9 | import numpy as np 10 | import itertools 11 | import pickle 12 | import os 13 | import re 14 | 15 | import inception_v4 16 | 17 | os.environ['CUDA_VISIBLE_DEVICES'] = '' 18 | 19 | def atoi(text): 20 | return int(text) if text.isdigit() else text 21 | 22 | def natural_keys(myobject): 23 | return [ atoi(c) for c in re.split('(\d+)', myobject.name) ] 24 | 25 | def setWeights(layers, weights): 26 | for index, layer in enumerate(layers): 27 | if "dense" in layer.name: 28 | continue 29 | layer.set_weights(weights[index]) 30 | print(layer.name + " weights have been set!") 31 | print("Finished Setting Weights!") 32 | 33 | def get_layers(model): 34 | # Get Trainable layers 35 | layers = model.layers 36 | layers.sort(key=natural_keys) 37 | result = [] 38 | for i in range(len(layers)): 39 | try: 40 | layer = model.layers[i] 41 | if layer.trainable: 42 | bad = ["pooling", "flatten", "dropout", "activation", "concatenate"] 43 | if not any(word in layer.name for word in bad): 44 | result.append(layer) 45 | except: 46 | continue 47 | bn,cv,fn=result[:int((len(result)-1)/2)],result[int((len(result)-1)/2):],result[-1] 48 | res_zipped = zip(cv, bn) 49 | out_prep = [list(elem) for elem in res_zipped] 50 | out = out_prep + [[fn]] 51 | return out 52 | 53 | 54 | if __name__ == "__main__": 55 | model = inception_v4.create_model() 56 | 57 | with open('weights.p', 'rb') as fp: 58 | weights = pickle.load(fp) 59 | 60 | # Get layers to set 61 | layers = get_layers(model) 62 | layers = list(itertools.chain.from_iterable(layers)) 63 | 64 | # Set the layer weights 65 | setWeights(layers, weights) 66 | 67 | # Save model weights in h5 format 68 | model.save_weights("../weights/inception-v4_weights_tf_dim_ordering_tf_kernels_notop.h5") 69 | print("Finished saving weights in h5 format") 70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/get_inception_weights.py: -------------------------------------------------------------------------------- 1 | import tensorflow as tf 2 | slim = tf.contrib.slim 3 | from helper_net.inception_v4 import * 4 | import pickle 5 | import numpy as np 6 | 7 | def get_weights(): 8 | checkpoint_file = '../checkpoints/inception_v4.ckpt' 9 | sess = tf.Session() 10 | arg_scope = inception_v4_arg_scope() 11 | input_tensor = tf.placeholder(tf.float32, (None, 299, 299, 3)) 12 | with slim.arg_scope(arg_scope): 13 | logits, end_points = inception_v4(input_tensor, is_training=False) 14 | saver = tf.train.Saver() 15 | saver.restore(sess, checkpoint_file) 16 | 17 | final_weights = [] 18 | current_bn = [] 19 | final_lr = [] 20 | 21 | vars_model = tf.global_variables() 22 | for i in range(0, len(vars_model), 4): 23 | for y in range(4): 24 | key = vars_model[i+y] 25 | if not "Aux" in key.name: 26 | if y in [1, 2, 3] and not "Logits" in key.name: 27 | value = sess.run(key) 28 | if y == 1: 29 | current_bn = [] 30 | current_bn.append(value) 31 | elif y == 2: 32 | current_bn.append(value) 33 | elif y == 3: 34 | current_bn.append(value) 35 | final_weights.append(current_bn) 36 | elif "Logits" in key.name: 37 | value = sess.run(key) 38 | if not "biases" in key.name: 39 | final_lr.append(value) 40 | else: 41 | final_lr.append(value) 42 | final_weights.append(final_lr) 43 | else: 44 | value = sess.run(key) 45 | final_weights.append([value]) 46 | with open('weights.p', 'wb') as fp: 47 | pickle.dump(final_weights, fp) 48 | 49 | if __name__ == "__main__": 50 | get_weights() -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/helper_net/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/xwzy/Triplet-deep-hash-pytorch/1bc58c6381e815ee3656b17892635acfb95d38bc/triplet-deep-hash-pytorch/src/extract_feature/convert_weights/helper_net/__init__.py -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/helper_net/inception_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Contains common code shared by all inception models. 16 | 17 | Usage of arg scope: 18 | with slim.arg_scope(inception_arg_scope()): 19 | logits, end_points = inception.inception_v3(images, num_classes, 20 | is_training=is_training) 21 | 22 | """ 23 | from __future__ import absolute_import 24 | from __future__ import division 25 | from __future__ import print_function 26 | 27 | import tensorflow as tf 28 | 29 | slim = tf.contrib.slim 30 | 31 | 32 | def inception_arg_scope(weight_decay=0.00004, 33 | use_batch_norm=True, 34 | batch_norm_decay=0.9997, 35 | batch_norm_epsilon=0.001): 36 | """Defines the default arg scope for inception models. 37 | 38 | Args: 39 | weight_decay: The weight decay to use for regularizing the model. 40 | use_batch_norm: "If `True`, batch_norm is applied after each convolution. 41 | batch_norm_decay: Decay for batch norm moving average. 42 | batch_norm_epsilon: Small float added to variance to avoid dividing by zero 43 | in batch norm. 44 | 45 | Returns: 46 | An `arg_scope` to use for the inception models. 47 | """ 48 | batch_norm_params = { 49 | # Decay for the moving averages. 50 | 'decay': batch_norm_decay, 51 | # epsilon to prevent 0s in variance. 52 | 'epsilon': batch_norm_epsilon, 53 | # collection containing update_ops. 54 | 'updates_collections': tf.GraphKeys.UPDATE_OPS, 55 | } 56 | if use_batch_norm: 57 | normalizer_fn = slim.batch_norm 58 | normalizer_params = batch_norm_params 59 | else: 60 | normalizer_fn = None 61 | normalizer_params = {} 62 | # Set weight_decay for weights in Conv and FC layers. 63 | with slim.arg_scope([slim.conv2d, slim.fully_connected], 64 | weights_regularizer=slim.l2_regularizer(weight_decay)): 65 | with slim.arg_scope( 66 | [slim.conv2d], 67 | weights_initializer=slim.variance_scaling_initializer(), 68 | activation_fn=tf.nn.relu, 69 | normalizer_fn=normalizer_fn, 70 | normalizer_params=normalizer_params) as sc: 71 | return sc -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/helper_net/inception_v4.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Contains the definition of the Inception V4 architecture. 16 | 17 | As described in http://arxiv.org/abs/1602.07261. 18 | 19 | Inception-v4, Inception-ResNet and the Impact of Residual Connections 20 | on Learning 21 | Christian Szegedy, Sergey Ioffe, Vincent Vanhoucke, Alex Alemi 22 | """ 23 | from __future__ import absolute_import 24 | from __future__ import division 25 | from __future__ import print_function 26 | 27 | import tensorflow as tf 28 | 29 | import inception_utils 30 | 31 | slim = tf.contrib.slim 32 | 33 | 34 | def block_inception_a(inputs, scope=None, reuse=None): 35 | """Builds Inception-A block for Inception v4 network.""" 36 | # By default use stride=1 and SAME padding 37 | with slim.arg_scope([slim.conv2d, slim.avg_pool2d, slim.max_pool2d], 38 | stride=1, padding='SAME'): 39 | with tf.variable_scope(scope, 'BlockInceptionA', [inputs], reuse=reuse): 40 | with tf.variable_scope('Branch_0'): 41 | branch_0 = slim.conv2d(inputs, 96, [1, 1], scope='Conv2d_0a_1x1') 42 | with tf.variable_scope('Branch_1'): 43 | branch_1 = slim.conv2d(inputs, 64, [1, 1], scope='Conv2d_0a_1x1') 44 | branch_1 = slim.conv2d(branch_1, 96, [3, 3], scope='Conv2d_0b_3x3') 45 | with tf.variable_scope('Branch_2'): 46 | branch_2 = slim.conv2d(inputs, 64, [1, 1], scope='Conv2d_0a_1x1') 47 | branch_2 = slim.conv2d(branch_2, 96, [3, 3], scope='Conv2d_0b_3x3') 48 | branch_2 = slim.conv2d(branch_2, 96, [3, 3], scope='Conv2d_0c_3x3') 49 | with tf.variable_scope('Branch_3'): 50 | branch_3 = slim.avg_pool2d(inputs, [3, 3], scope='AvgPool_0a_3x3') 51 | branch_3 = slim.conv2d(branch_3, 96, [1, 1], scope='Conv2d_0b_1x1') 52 | return tf.concat(axis=3, values=[branch_0, branch_1, branch_2, branch_3]) 53 | 54 | 55 | def block_reduction_a(inputs, scope=None, reuse=None): 56 | """Builds Reduction-A block for Inception v4 network.""" 57 | # By default use stride=1 and SAME padding 58 | with slim.arg_scope([slim.conv2d, slim.avg_pool2d, slim.max_pool2d], 59 | stride=1, padding='SAME'): 60 | with tf.variable_scope(scope, 'BlockReductionA', [inputs], reuse=reuse): 61 | with tf.variable_scope('Branch_0'): 62 | branch_0 = slim.conv2d(inputs, 384, [3, 3], stride=2, padding='VALID', 63 | scope='Conv2d_1a_3x3') 64 | with tf.variable_scope('Branch_1'): 65 | branch_1 = slim.conv2d(inputs, 192, [1, 1], scope='Conv2d_0a_1x1') 66 | branch_1 = slim.conv2d(branch_1, 224, [3, 3], scope='Conv2d_0b_3x3') 67 | branch_1 = slim.conv2d(branch_1, 256, [3, 3], stride=2, 68 | padding='VALID', scope='Conv2d_1a_3x3') 69 | with tf.variable_scope('Branch_2'): 70 | branch_2 = slim.max_pool2d(inputs, [3, 3], stride=2, padding='VALID', 71 | scope='MaxPool_1a_3x3') 72 | return tf.concat(axis=3, values=[branch_0, branch_1, branch_2]) 73 | 74 | 75 | def block_inception_b(inputs, scope=None, reuse=None): 76 | """Builds Inception-B block for Inception v4 network.""" 77 | # By default use stride=1 and SAME padding 78 | with slim.arg_scope([slim.conv2d, slim.avg_pool2d, slim.max_pool2d], 79 | stride=1, padding='SAME'): 80 | with tf.variable_scope(scope, 'BlockInceptionB', [inputs], reuse=reuse): 81 | with tf.variable_scope('Branch_0'): 82 | branch_0 = slim.conv2d(inputs, 384, [1, 1], scope='Conv2d_0a_1x1') 83 | with tf.variable_scope('Branch_1'): 84 | branch_1 = slim.conv2d(inputs, 192, [1, 1], scope='Conv2d_0a_1x1') 85 | branch_1 = slim.conv2d(branch_1, 224, [1, 7], scope='Conv2d_0b_1x7') 86 | branch_1 = slim.conv2d(branch_1, 256, [7, 1], scope='Conv2d_0c_7x1') 87 | with tf.variable_scope('Branch_2'): 88 | branch_2 = slim.conv2d(inputs, 192, [1, 1], scope='Conv2d_0a_1x1') 89 | branch_2 = slim.conv2d(branch_2, 192, [7, 1], scope='Conv2d_0b_7x1') 90 | branch_2 = slim.conv2d(branch_2, 224, [1, 7], scope='Conv2d_0c_1x7') 91 | branch_2 = slim.conv2d(branch_2, 224, [7, 1], scope='Conv2d_0d_7x1') 92 | branch_2 = slim.conv2d(branch_2, 256, [1, 7], scope='Conv2d_0e_1x7') 93 | with tf.variable_scope('Branch_3'): 94 | branch_3 = slim.avg_pool2d(inputs, [3, 3], scope='AvgPool_0a_3x3') 95 | branch_3 = slim.conv2d(branch_3, 128, [1, 1], scope='Conv2d_0b_1x1') 96 | return tf.concat(axis=3, values=[branch_0, branch_1, branch_2, branch_3]) 97 | 98 | 99 | def block_reduction_b(inputs, scope=None, reuse=None): 100 | """Builds Reduction-B block for Inception v4 network.""" 101 | # By default use stride=1 and SAME padding 102 | with slim.arg_scope([slim.conv2d, slim.avg_pool2d, slim.max_pool2d], 103 | stride=1, padding='SAME'): 104 | with tf.variable_scope(scope, 'BlockReductionB', [inputs], reuse=reuse): 105 | with tf.variable_scope('Branch_0'): 106 | branch_0 = slim.conv2d(inputs, 192, [1, 1], scope='Conv2d_0a_1x1') 107 | branch_0 = slim.conv2d(branch_0, 192, [3, 3], stride=2, 108 | padding='VALID', scope='Conv2d_1a_3x3') 109 | with tf.variable_scope('Branch_1'): 110 | branch_1 = slim.conv2d(inputs, 256, [1, 1], scope='Conv2d_0a_1x1') 111 | branch_1 = slim.conv2d(branch_1, 256, [1, 7], scope='Conv2d_0b_1x7') 112 | branch_1 = slim.conv2d(branch_1, 320, [7, 1], scope='Conv2d_0c_7x1') 113 | branch_1 = slim.conv2d(branch_1, 320, [3, 3], stride=2, 114 | padding='VALID', scope='Conv2d_1a_3x3') 115 | with tf.variable_scope('Branch_2'): 116 | branch_2 = slim.max_pool2d(inputs, [3, 3], stride=2, padding='VALID', 117 | scope='MaxPool_1a_3x3') 118 | return tf.concat(axis=3, values=[branch_0, branch_1, branch_2]) 119 | 120 | 121 | def block_inception_c(inputs, scope=None, reuse=None): 122 | """Builds Inception-C block for Inception v4 network.""" 123 | # By default use stride=1 and SAME padding 124 | with slim.arg_scope([slim.conv2d, slim.avg_pool2d, slim.max_pool2d], 125 | stride=1, padding='SAME'): 126 | with tf.variable_scope(scope, 'BlockInceptionC', [inputs], reuse=reuse): 127 | with tf.variable_scope('Branch_0'): 128 | branch_0 = slim.conv2d(inputs, 256, [1, 1], scope='Conv2d_0a_1x1') 129 | with tf.variable_scope('Branch_1'): 130 | branch_1 = slim.conv2d(inputs, 384, [1, 1], scope='Conv2d_0a_1x1') 131 | branch_1 = tf.concat(axis=3, values=[ 132 | slim.conv2d(branch_1, 256, [1, 3], scope='Conv2d_0b_1x3'), 133 | slim.conv2d(branch_1, 256, [3, 1], scope='Conv2d_0c_3x1')]) 134 | with tf.variable_scope('Branch_2'): 135 | branch_2 = slim.conv2d(inputs, 384, [1, 1], scope='Conv2d_0a_1x1') 136 | branch_2 = slim.conv2d(branch_2, 448, [3, 1], scope='Conv2d_0b_3x1') 137 | branch_2 = slim.conv2d(branch_2, 512, [1, 3], scope='Conv2d_0c_1x3') 138 | branch_2 = tf.concat(axis=3, values=[ 139 | slim.conv2d(branch_2, 256, [1, 3], scope='Conv2d_0d_1x3'), 140 | slim.conv2d(branch_2, 256, [3, 1], scope='Conv2d_0e_3x1')]) 141 | with tf.variable_scope('Branch_3'): 142 | branch_3 = slim.avg_pool2d(inputs, [3, 3], scope='AvgPool_0a_3x3') 143 | branch_3 = slim.conv2d(branch_3, 256, [1, 1], scope='Conv2d_0b_1x1') 144 | return tf.concat(axis=3, values=[branch_0, branch_1, branch_2, branch_3]) 145 | 146 | 147 | def inception_v4_base(inputs, final_endpoint='Mixed_7d', scope=None): 148 | """Creates the Inception V4 network up to the given final endpoint. 149 | 150 | Args: 151 | inputs: a 4-D tensor of size [batch_size, height, width, 3]. 152 | final_endpoint: specifies the endpoint to construct the network up to. 153 | It can be one of [ 'Conv2d_1a_3x3', 'Conv2d_2a_3x3', 'Conv2d_2b_3x3', 154 | 'Mixed_3a', 'Mixed_4a', 'Mixed_5a', 'Mixed_5b', 'Mixed_5c', 'Mixed_5d', 155 | 'Mixed_5e', 'Mixed_6a', 'Mixed_6b', 'Mixed_6c', 'Mixed_6d', 'Mixed_6e', 156 | 'Mixed_6f', 'Mixed_6g', 'Mixed_6h', 'Mixed_7a', 'Mixed_7b', 'Mixed_7c', 157 | 'Mixed_7d'] 158 | scope: Optional variable_scope. 159 | 160 | Returns: 161 | logits: the logits outputs of the model. 162 | end_points: the set of end_points from the inception model. 163 | 164 | Raises: 165 | ValueError: if final_endpoint is not set to one of the predefined values, 166 | """ 167 | end_points = {} 168 | 169 | def add_and_check_final(name, net): 170 | end_points[name] = net 171 | return name == final_endpoint 172 | 173 | with tf.variable_scope(scope, 'InceptionV4', [inputs]): 174 | with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d], 175 | stride=1, padding='SAME'): 176 | # 299 x 299 x 3 177 | net = slim.conv2d(inputs, 32, [3, 3], stride=2, 178 | padding='VALID', scope='Conv2d_1a_3x3') 179 | if add_and_check_final('Conv2d_1a_3x3', net): return net, end_points 180 | # 149 x 149 x 32 181 | net = slim.conv2d(net, 32, [3, 3], padding='VALID', 182 | scope='Conv2d_2a_3x3') 183 | if add_and_check_final('Conv2d_2a_3x3', net): return net, end_points 184 | # 147 x 147 x 32 185 | net = slim.conv2d(net, 64, [3, 3], scope='Conv2d_2b_3x3') 186 | if add_and_check_final('Conv2d_2b_3x3', net): return net, end_points 187 | # 147 x 147 x 64 188 | with tf.variable_scope('Mixed_3a'): 189 | with tf.variable_scope('Branch_0'): 190 | branch_0 = slim.max_pool2d(net, [3, 3], stride=2, padding='VALID', 191 | scope='MaxPool_0a_3x3') 192 | with tf.variable_scope('Branch_1'): 193 | branch_1 = slim.conv2d(net, 96, [3, 3], stride=2, padding='VALID', 194 | scope='Conv2d_0a_3x3') 195 | net = tf.concat(axis=3, values=[branch_0, branch_1]) 196 | if add_and_check_final('Mixed_3a', net): return net, end_points 197 | 198 | # 73 x 73 x 160 199 | with tf.variable_scope('Mixed_4a'): 200 | with tf.variable_scope('Branch_0'): 201 | branch_0 = slim.conv2d(net, 64, [1, 1], scope='Conv2d_0a_1x1') 202 | branch_0 = slim.conv2d(branch_0, 96, [3, 3], padding='VALID', 203 | scope='Conv2d_1a_3x3') 204 | with tf.variable_scope('Branch_1'): 205 | branch_1 = slim.conv2d(net, 64, [1, 1], scope='Conv2d_0a_1x1') 206 | branch_1 = slim.conv2d(branch_1, 64, [1, 7], scope='Conv2d_0b_1x7') 207 | branch_1 = slim.conv2d(branch_1, 64, [7, 1], scope='Conv2d_0c_7x1') 208 | branch_1 = slim.conv2d(branch_1, 96, [3, 3], padding='VALID', 209 | scope='Conv2d_1a_3x3') 210 | net = tf.concat(axis=3, values=[branch_0, branch_1]) 211 | if add_and_check_final('Mixed_4a', net): return net, end_points 212 | 213 | # 71 x 71 x 192 214 | with tf.variable_scope('Mixed_5a'): 215 | with tf.variable_scope('Branch_0'): 216 | branch_0 = slim.conv2d(net, 192, [3, 3], stride=2, padding='VALID', 217 | scope='Conv2d_1a_3x3') 218 | with tf.variable_scope('Branch_1'): 219 | branch_1 = slim.max_pool2d(net, [3, 3], stride=2, padding='VALID', 220 | scope='MaxPool_1a_3x3') 221 | net = tf.concat(axis=3, values=[branch_0, branch_1]) 222 | if add_and_check_final('Mixed_5a', net): return net, end_points 223 | 224 | # 35 x 35 x 384 225 | # 4 x Inception-A blocks 226 | for idx in xrange(4): 227 | block_scope = 'Mixed_5' + chr(ord('b') + idx) 228 | net = block_inception_a(net, block_scope) 229 | if add_and_check_final(block_scope, net): return net, end_points 230 | 231 | # 35 x 35 x 384 232 | # Reduction-A block 233 | net = block_reduction_a(net, 'Mixed_6a') 234 | if add_and_check_final('Mixed_6a', net): return net, end_points 235 | 236 | # 17 x 17 x 1024 237 | # 7 x Inception-B blocks 238 | for idx in xrange(7): 239 | block_scope = 'Mixed_6' + chr(ord('b') + idx) 240 | net = block_inception_b(net, block_scope) 241 | if add_and_check_final(block_scope, net): return net, end_points 242 | 243 | # 17 x 17 x 1024 244 | # Reduction-B block 245 | net = block_reduction_b(net, 'Mixed_7a') 246 | if add_and_check_final('Mixed_7a', net): return net, end_points 247 | 248 | # 8 x 8 x 1536 249 | # 3 x Inception-C blocks 250 | for idx in xrange(3): 251 | block_scope = 'Mixed_7' + chr(ord('b') + idx) 252 | net = block_inception_c(net, block_scope) 253 | if add_and_check_final(block_scope, net): return net, end_points 254 | raise ValueError('Unknown final endpoint %s' % final_endpoint) 255 | 256 | 257 | def inception_v4(inputs, num_classes=1001, is_training=True, 258 | dropout_keep_prob=0.8, 259 | reuse=None, 260 | scope='InceptionV4', 261 | create_aux_logits=True): 262 | """Creates the Inception V4 model. 263 | 264 | Args: 265 | inputs: a 4-D tensor of size [batch_size, height, width, 3]. 266 | num_classes: number of predicted classes. 267 | is_training: whether is training or not. 268 | dropout_keep_prob: float, the fraction to keep before final layer. 269 | reuse: whether or not the network and its variables should be reused. To be 270 | able to reuse 'scope' must be given. 271 | scope: Optional variable_scope. 272 | create_aux_logits: Whether to include the auxiliary logits. 273 | 274 | Returns: 275 | logits: the logits outputs of the model. 276 | end_points: the set of end_points from the inception model. 277 | """ 278 | end_points = {} 279 | with tf.variable_scope(scope, 'InceptionV4', [inputs], reuse=reuse) as scope: 280 | with slim.arg_scope([slim.batch_norm, slim.dropout], 281 | is_training=is_training): 282 | net, end_points = inception_v4_base(inputs, scope=scope) 283 | 284 | with slim.arg_scope([slim.conv2d, slim.max_pool2d, slim.avg_pool2d], 285 | stride=1, padding='SAME'): 286 | # Auxiliary Head logits 287 | if create_aux_logits: 288 | with tf.variable_scope('AuxLogits'): 289 | # 17 x 17 x 1024 290 | aux_logits = end_points['Mixed_6h'] 291 | aux_logits = slim.avg_pool2d(aux_logits, [5, 5], stride=3, 292 | padding='VALID', 293 | scope='AvgPool_1a_5x5') 294 | aux_logits = slim.conv2d(aux_logits, 128, [1, 1], 295 | scope='Conv2d_1b_1x1') 296 | aux_logits = slim.conv2d(aux_logits, 768, 297 | aux_logits.get_shape()[1:3], 298 | padding='VALID', scope='Conv2d_2a') 299 | aux_logits = slim.flatten(aux_logits) 300 | aux_logits = slim.fully_connected(aux_logits, num_classes, 301 | activation_fn=None, 302 | scope='Aux_logits') 303 | end_points['AuxLogits'] = aux_logits 304 | 305 | # Final pooling and prediction 306 | with tf.variable_scope('Logits'): 307 | # 8 x 8 x 1536 308 | net = slim.avg_pool2d(net, net.get_shape()[1:3], padding='VALID', 309 | scope='AvgPool_1a') 310 | # 1 x 1 x 1536 311 | net = slim.dropout(net, dropout_keep_prob, scope='Dropout_1b') 312 | net = slim.flatten(net, scope='PreLogitsFlatten') 313 | end_points['PreLogitsFlatten'] = net 314 | # 1536 315 | logits = slim.fully_connected(net, num_classes, activation_fn=None, 316 | scope='Logits') 317 | end_points['Logits'] = logits 318 | end_points['Predictions'] = tf.nn.softmax(logits, name='Predictions') 319 | return logits, end_points 320 | inception_v4.default_image_size = 299 321 | 322 | 323 | inception_v4_arg_scope = inception_utils.inception_arg_scope -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/convert_weights/inception_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright 2016 The TensorFlow Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | # ============================================================================== 15 | """Contains common code shared by all inception models. 16 | 17 | Usage of arg scope: 18 | with slim.arg_scope(inception_arg_scope()): 19 | logits, end_points = inception.inception_v3(images, num_classes, 20 | is_training=is_training) 21 | 22 | """ 23 | from __future__ import absolute_import 24 | from __future__ import division 25 | from __future__ import print_function 26 | 27 | import tensorflow as tf 28 | 29 | slim = tf.contrib.slim 30 | 31 | 32 | def inception_arg_scope(weight_decay=0.00004, 33 | use_batch_norm=True, 34 | batch_norm_decay=0.9997, 35 | batch_norm_epsilon=0.001): 36 | """Defines the default arg scope for inception models. 37 | 38 | Args: 39 | weight_decay: The weight decay to use for regularizing the model. 40 | use_batch_norm: "If `True`, batch_norm is applied after each convolution. 41 | batch_norm_decay: Decay for batch norm moving average. 42 | batch_norm_epsilon: Small float added to variance to avoid dividing by zero 43 | in batch norm. 44 | 45 | Returns: 46 | An `arg_scope` to use for the inception models. 47 | """ 48 | batch_norm_params = { 49 | # Decay for the moving averages. 50 | 'decay': batch_norm_decay, 51 | # epsilon to prevent 0s in variance. 52 | 'epsilon': batch_norm_epsilon, 53 | # collection containing update_ops. 54 | 'updates_collections': tf.GraphKeys.UPDATE_OPS, 55 | } 56 | if use_batch_norm: 57 | normalizer_fn = slim.batch_norm 58 | normalizer_params = batch_norm_params 59 | else: 60 | normalizer_fn = None 61 | normalizer_params = {} 62 | # Set weight_decay for weights in Conv and FC layers. 63 | with slim.arg_scope([slim.conv2d, slim.fully_connected], 64 | weights_regularizer=slim.l2_regularizer(weight_decay)): 65 | with slim.arg_scope( 66 | [slim.conv2d], 67 | weights_initializer=slim.variance_scaling_initializer(), 68 | activation_fn=tf.nn.relu, 69 | normalizer_fn=normalizer_fn, 70 | normalizer_params=normalizer_params) as sc: 71 | return sc -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/evaluate_image.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright 2017 TensorFlow Authors and Kent Sommer 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ''' 16 | from keras import backend as K 17 | import inception_v4 18 | import numpy as np 19 | import cv2 20 | import os 21 | 22 | # If you want to use a GPU set its index here 23 | os.environ['CUDA_VISIBLE_DEVICES'] = '' 24 | 25 | 26 | # This function comes from Google's ImageNet Preprocessing Script 27 | def central_crop(image, central_fraction): 28 | """Crop the central region of the image. 29 | Remove the outer parts of an image but retain the central region of the image 30 | along each dimension. If we specify central_fraction = 0.5, this function 31 | returns the region marked with "X" in the below diagram. 32 | -------- 33 | | | 34 | | XXXX | 35 | | XXXX | 36 | | | where "X" is the central 50% of the image. 37 | -------- 38 | Args: 39 | image: 3-D array of shape [height, width, depth] 40 | central_fraction: float (0, 1], fraction of size to crop 41 | Raises: 42 | ValueError: if central_crop_fraction is not within (0, 1]. 43 | Returns: 44 | 3-D array 45 | """ 46 | if central_fraction <= 0.0 or central_fraction > 1.0: 47 | raise ValueError('central_fraction must be within (0, 1]') 48 | if central_fraction == 1.0: 49 | return image 50 | 51 | img_shape = image.shape 52 | depth = img_shape[2] 53 | fraction_offset = int(1 / ((1 - central_fraction) / 2.0)) 54 | bbox_h_start = int(np.divide(img_shape[0], fraction_offset)) 55 | bbox_w_start = int(np.divide(img_shape[1], fraction_offset)) 56 | 57 | bbox_h_size = int(img_shape[0] - bbox_h_start * 2) 58 | bbox_w_size = int(img_shape[1] - bbox_w_start * 2) 59 | 60 | image = image[bbox_h_start:bbox_h_start + bbox_h_size, bbox_w_start:bbox_w_start + bbox_w_size] 61 | return image 62 | 63 | 64 | def get_processed_image(img_path): 65 | # Load image and convert from BGR to RGB 66 | im = np.asarray(cv2.imread(img_path))[:, :, ::-1] 67 | im = central_crop(im, 0.875) 68 | im = cv2.resize(im, (299, 299)) 69 | im = inception_v4.preprocess_input(im) 70 | if K.image_data_format() == "channels_first": 71 | im = np.transpose(im, (2, 0, 1)) 72 | im = im.reshape(-1, 3, 299, 299) 73 | else: 74 | im = im.reshape(-1, 299, 299, 3) 75 | return im 76 | 77 | 78 | if __name__ == "__main__": 79 | # Create model and load pre-trained weights 80 | # model = inception_v4.create_model(weights='imagenet', include_top=True) 81 | model = inception_v4.create_model(weights='imagenet', include_top=False) 82 | 83 | # Open Class labels dictionary. (human readable label given ID) 84 | classes = eval(open('validation_utils/class_names.txt', 'r').read()) 85 | 86 | # Load test image! 87 | img_path = '../JDpig/origin/28/8.jpg' 88 | img = get_processed_image(img_path) 89 | 90 | # Run prediction on test image 91 | preds = model.predict(img) 92 | print(preds) 93 | # print("Class is: " + classes[np.argmax(preds)-1]) 94 | # print("Certainty is: " + str(preds[0][np.argmax(preds)])) 95 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/inception_v4.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright 2017 TensorFlow Authors and Kent Sommer 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ''' 16 | import numpy as np 17 | 18 | # Sys 19 | import warnings 20 | # Keras Core 21 | from keras.layers.convolutional import MaxPooling2D, Convolution2D, AveragePooling2D 22 | from keras.layers import Input, Dropout, Dense, Flatten, Activation 23 | from keras.layers.normalization import BatchNormalization 24 | from keras.layers.merge import concatenate 25 | from keras import regularizers 26 | from keras import initializers 27 | from keras.models import Model 28 | # Backend 29 | from keras import backend as K 30 | # Utils 31 | from keras.utils.layer_utils import convert_all_kernels_in_model 32 | from keras.utils.data_utils import get_file 33 | 34 | ######################################################################################### 35 | # Implements the Inception Network v4 (http://arxiv.org/pdf/1602.07261v1.pdf) in Keras. # 36 | ######################################################################################### 37 | 38 | WEIGHTS_PATH = 'https://github.com/kentsommer/keras-inceptionV4/releases/download/2.1/inception-v4_weights_tf_dim_ordering_tf_kernels.h5' 39 | WEIGHTS_PATH_NO_TOP = 'https://github.com/kentsommer/keras-inceptionV4/releases/download/2.1/inception-v4_weights_tf_dim_ordering_tf_kernels_notop.h5' 40 | 41 | 42 | def preprocess_input(x): 43 | x = np.divide(x, 255.0) 44 | x = np.subtract(x, 0.5) 45 | x = np.multiply(x, 2.0) 46 | return x 47 | 48 | 49 | def conv2d_bn(x, nb_filter, num_row, num_col, 50 | padding='same', strides=(1, 1), use_bias=False): 51 | """ 52 | Utility function to apply conv + BN. 53 | (Slightly modified from https://github.com/fchollet/keras/blob/master/keras/applications/inception_v3.py) 54 | """ 55 | if K.image_data_format() == 'channels_first': 56 | channel_axis = 1 57 | else: 58 | channel_axis = -1 59 | x = Convolution2D(nb_filter, (num_row, num_col), 60 | strides=strides, 61 | padding=padding, 62 | use_bias=use_bias, 63 | kernel_regularizer=regularizers.l2(0.00004), 64 | kernel_initializer=initializers.VarianceScaling(scale=2.0, mode='fan_in', distribution='normal', 65 | seed=None))(x) 66 | x = BatchNormalization(axis=channel_axis, momentum=0.9997, scale=False)(x) 67 | x = Activation('relu')(x) 68 | return x 69 | 70 | 71 | def block_inception_a(input): 72 | if K.image_data_format() == 'channels_first': 73 | channel_axis = 1 74 | else: 75 | channel_axis = -1 76 | 77 | branch_0 = conv2d_bn(input, 96, 1, 1) 78 | 79 | branch_1 = conv2d_bn(input, 64, 1, 1) 80 | branch_1 = conv2d_bn(branch_1, 96, 3, 3) 81 | 82 | branch_2 = conv2d_bn(input, 64, 1, 1) 83 | branch_2 = conv2d_bn(branch_2, 96, 3, 3) 84 | branch_2 = conv2d_bn(branch_2, 96, 3, 3) 85 | 86 | branch_3 = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(input) 87 | branch_3 = conv2d_bn(branch_3, 96, 1, 1) 88 | 89 | x = concatenate([branch_0, branch_1, branch_2, branch_3], axis=channel_axis) 90 | return x 91 | 92 | 93 | def block_reduction_a(input): 94 | if K.image_data_format() == 'channels_first': 95 | channel_axis = 1 96 | else: 97 | channel_axis = -1 98 | 99 | branch_0 = conv2d_bn(input, 384, 3, 3, strides=(2, 2), padding='valid') 100 | 101 | branch_1 = conv2d_bn(input, 192, 1, 1) 102 | branch_1 = conv2d_bn(branch_1, 224, 3, 3) 103 | branch_1 = conv2d_bn(branch_1, 256, 3, 3, strides=(2, 2), padding='valid') 104 | 105 | branch_2 = MaxPooling2D((3, 3), strides=(2, 2), padding='valid')(input) 106 | 107 | x = concatenate([branch_0, branch_1, branch_2], axis=channel_axis) 108 | return x 109 | 110 | 111 | def block_inception_b(input): 112 | if K.image_data_format() == 'channels_first': 113 | channel_axis = 1 114 | else: 115 | channel_axis = -1 116 | 117 | branch_0 = conv2d_bn(input, 384, 1, 1) 118 | 119 | branch_1 = conv2d_bn(input, 192, 1, 1) 120 | branch_1 = conv2d_bn(branch_1, 224, 1, 7) 121 | branch_1 = conv2d_bn(branch_1, 256, 7, 1) 122 | 123 | branch_2 = conv2d_bn(input, 192, 1, 1) 124 | branch_2 = conv2d_bn(branch_2, 192, 7, 1) 125 | branch_2 = conv2d_bn(branch_2, 224, 1, 7) 126 | branch_2 = conv2d_bn(branch_2, 224, 7, 1) 127 | branch_2 = conv2d_bn(branch_2, 256, 1, 7) 128 | 129 | branch_3 = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(input) 130 | branch_3 = conv2d_bn(branch_3, 128, 1, 1) 131 | 132 | x = concatenate([branch_0, branch_1, branch_2, branch_3], axis=channel_axis) 133 | return x 134 | 135 | 136 | def block_reduction_b(input): 137 | if K.image_data_format() == 'channels_first': 138 | channel_axis = 1 139 | else: 140 | channel_axis = -1 141 | 142 | branch_0 = conv2d_bn(input, 192, 1, 1) 143 | branch_0 = conv2d_bn(branch_0, 192, 3, 3, strides=(2, 2), padding='valid') 144 | 145 | branch_1 = conv2d_bn(input, 256, 1, 1) 146 | branch_1 = conv2d_bn(branch_1, 256, 1, 7) 147 | branch_1 = conv2d_bn(branch_1, 320, 7, 1) 148 | branch_1 = conv2d_bn(branch_1, 320, 3, 3, strides=(2, 2), padding='valid') 149 | 150 | branch_2 = MaxPooling2D((3, 3), strides=(2, 2), padding='valid')(input) 151 | 152 | x = concatenate([branch_0, branch_1, branch_2], axis=channel_axis) 153 | return x 154 | 155 | 156 | def block_inception_c(input): 157 | if K.image_data_format() == 'channels_first': 158 | channel_axis = 1 159 | else: 160 | channel_axis = -1 161 | 162 | branch_0 = conv2d_bn(input, 256, 1, 1) 163 | 164 | branch_1 = conv2d_bn(input, 384, 1, 1) 165 | branch_10 = conv2d_bn(branch_1, 256, 1, 3) 166 | branch_11 = conv2d_bn(branch_1, 256, 3, 1) 167 | branch_1 = concatenate([branch_10, branch_11], axis=channel_axis) 168 | 169 | branch_2 = conv2d_bn(input, 384, 1, 1) 170 | branch_2 = conv2d_bn(branch_2, 448, 3, 1) 171 | branch_2 = conv2d_bn(branch_2, 512, 1, 3) 172 | branch_20 = conv2d_bn(branch_2, 256, 1, 3) 173 | branch_21 = conv2d_bn(branch_2, 256, 3, 1) 174 | branch_2 = concatenate([branch_20, branch_21], axis=channel_axis) 175 | 176 | branch_3 = AveragePooling2D((3, 3), strides=(1, 1), padding='same')(input) 177 | branch_3 = conv2d_bn(branch_3, 256, 1, 1) 178 | 179 | x = concatenate([branch_0, branch_1, branch_2, branch_3], axis=channel_axis) 180 | return x 181 | 182 | 183 | def inception_v4_base(input): 184 | if K.image_data_format() == 'channels_first': 185 | channel_axis = 1 186 | else: 187 | channel_axis = -1 188 | 189 | # Input Shape is 299 x 299 x 3 (th) or 3 x 299 x 299 (th) 190 | net = conv2d_bn(input, 32, 3, 3, strides=(2, 2), padding='valid') 191 | net = conv2d_bn(net, 32, 3, 3, padding='valid') 192 | net = conv2d_bn(net, 64, 3, 3) 193 | 194 | branch_0 = MaxPooling2D((3, 3), strides=(2, 2), padding='valid')(net) 195 | 196 | branch_1 = conv2d_bn(net, 96, 3, 3, strides=(2, 2), padding='valid') 197 | 198 | net = concatenate([branch_0, branch_1], axis=channel_axis) 199 | 200 | branch_0 = conv2d_bn(net, 64, 1, 1) 201 | branch_0 = conv2d_bn(branch_0, 96, 3, 3, padding='valid') 202 | 203 | branch_1 = conv2d_bn(net, 64, 1, 1) 204 | branch_1 = conv2d_bn(branch_1, 64, 1, 7) 205 | branch_1 = conv2d_bn(branch_1, 64, 7, 1) 206 | branch_1 = conv2d_bn(branch_1, 96, 3, 3, padding='valid') 207 | 208 | net = concatenate([branch_0, branch_1], axis=channel_axis) 209 | 210 | branch_0 = conv2d_bn(net, 192, 3, 3, strides=(2, 2), padding='valid') 211 | branch_1 = MaxPooling2D((3, 3), strides=(2, 2), padding='valid')(net) 212 | 213 | net = concatenate([branch_0, branch_1], axis=channel_axis) 214 | 215 | # 35 x 35 x 384 216 | # 4 x Inception-A blocks 217 | for idx in range(4): 218 | net = block_inception_a(net) 219 | 220 | # 35 x 35 x 384 221 | # Reduction-A block 222 | net = block_reduction_a(net) 223 | 224 | # 17 x 17 x 1024 225 | # 7 x Inception-B blocks 226 | for idx in range(7): 227 | net = block_inception_b(net) 228 | 229 | # 17 x 17 x 1024 230 | # Reduction-B block 231 | net = block_reduction_b(net) 232 | 233 | # 8 x 8 x 1536 234 | # 3 x Inception-C blocks 235 | for idx in range(3): 236 | net = block_inception_c(net) 237 | 238 | return net 239 | 240 | 241 | def inception_v4(num_classes, dropout_keep_prob, weights, include_top): 242 | ''' 243 | Creates the inception v4 network 244 | 245 | Args: 246 | num_classes: number of classes 247 | dropout_keep_prob: float, the fraction to keep before final layer. 248 | 249 | Returns: 250 | logits: the logits outputs of the model. 251 | ''' 252 | 253 | # Input Shape is 299 x 299 x 3 (tf) or 3 x 299 x 299 (th) 254 | if K.image_data_format() == 'channels_first': 255 | inputs = Input((3, 299, 299)) 256 | else: 257 | inputs = Input((299, 299, 3)) 258 | 259 | # Make inception base 260 | x = inception_v4_base(inputs) 261 | 262 | # Final pooling and prediction 263 | if include_top: 264 | # 1 x 1 x 1536 265 | x = AveragePooling2D((8, 8), padding='valid')(x) 266 | x = Dropout(dropout_keep_prob)(x) 267 | x = Flatten()(x) 268 | # 1536 269 | x = Dense(units=num_classes, activation='softmax')(x) 270 | 271 | model = Model(inputs, x, name='inception_v4') 272 | 273 | # load weights 274 | if weights == 'imagenet': 275 | if K.image_data_format() == 'channels_first': 276 | if K.backend() == 'tensorflow': 277 | warnings.warn('You are using the TensorFlow backend, yet you ' 278 | 'are using the Theano ' 279 | 'image data format convention ' 280 | '(`image_data_format="channels_first"`). ' 281 | 'For best performance, set ' 282 | '`image_data_format="channels_last"` in ' 283 | 'your Keras config ' 284 | 'at ~/.keras/keras.json.') 285 | if include_top: 286 | weights_path = get_file( 287 | 'inception-v4_weights_tf_dim_ordering_tf_kernels.h5', 288 | WEIGHTS_PATH, 289 | cache_subdir='models', 290 | md5_hash='9fe79d77f793fe874470d84ca6ba4a3b') 291 | else: 292 | weights_path = get_file( 293 | 'inception-v4_weights_tf_dim_ordering_tf_kernels_notop.h5', 294 | WEIGHTS_PATH_NO_TOP, 295 | cache_subdir='models', 296 | md5_hash='9296b46b5971573064d12e4669110969') 297 | model.load_weights(weights_path, by_name=True) 298 | return model 299 | 300 | 301 | def create_model(num_classes=1001, dropout_prob=0.2, weights=None, include_top=True): 302 | return inception_v4(num_classes, dropout_prob, weights, include_top) 303 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/validation_utils/class_names.txt: -------------------------------------------------------------------------------- 1 | { 2 | 0: 'tench, Tinca tinca', 3 | 1: 'goldfish, Carassius auratus', 4 | 2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', 5 | 3: 'tiger shark, Galeocerdo cuvieri', 6 | 4: 'hammerhead, hammerhead shark', 7 | 5: 'electric ray, crampfish, numbfish, torpedo', 8 | 6: 'stingray', 9 | 7: 'cock', 10 | 8: 'hen', 11 | 9: 'ostrich, Struthio camelus', 12 | 10: 'brambling, Fringilla montifringilla', 13 | 11: 'goldfinch, Carduelis carduelis', 14 | 12: 'house finch, linnet, Carpodacus mexicanus', 15 | 13: 'junco, snowbird', 16 | 14: 'indigo bunting, indigo finch, indigo bird, Passerina cyanea', 17 | 15: 'robin, American robin, Turdus migratorius', 18 | 16: 'bulbul', 19 | 17: 'jay', 20 | 18: 'magpie', 21 | 19: 'chickadee', 22 | 20: 'water ouzel, dipper', 23 | 21: 'kite', 24 | 22: 'bald eagle, American eagle, Haliaeetus leucocephalus', 25 | 23: 'vulture', 26 | 24: 'great grey owl, great gray owl, Strix nebulosa', 27 | 25: 'European fire salamander, Salamandra salamandra', 28 | 26: 'common newt, Triturus vulgaris', 29 | 27: 'eft', 30 | 28: 'spotted salamander, Ambystoma maculatum', 31 | 29: 'axolotl, mud puppy, Ambystoma mexicanum', 32 | 30: 'bullfrog, Rana catesbeiana', 33 | 31: 'tree frog, tree-frog', 34 | 32: 'tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui', 35 | 33: 'loggerhead, loggerhead turtle, Caretta caretta', 36 | 34: 'leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea', 37 | 35: 'mud turtle', 38 | 36: 'terrapin', 39 | 37: 'box turtle, box tortoise', 40 | 38: 'banded gecko', 41 | 39: 'common iguana, iguana, Iguana iguana', 42 | 40: 'American chameleon, anole, Anolis carolinensis', 43 | 41: 'whiptail, whiptail lizard', 44 | 42: 'agama', 45 | 43: 'frilled lizard, Chlamydosaurus kingi', 46 | 44: 'alligator lizard', 47 | 45: 'Gila monster, Heloderma suspectum', 48 | 46: 'green lizard, Lacerta viridis', 49 | 47: 'African chameleon, Chamaeleo chamaeleon', 50 | 48: 'Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis', 51 | 49: 'African crocodile, Nile crocodile, Crocodylus niloticus', 52 | 50: 'American alligator, Alligator mississipiensis', 53 | 51: 'triceratops', 54 | 52: 'thunder snake, worm snake, Carphophis amoenus', 55 | 53: 'ringneck snake, ring-necked snake, ring snake', 56 | 54: 'hognose snake, puff adder, sand viper', 57 | 55: 'green snake, grass snake', 58 | 56: 'king snake, kingsnake', 59 | 57: 'garter snake, grass snake', 60 | 58: 'water snake', 61 | 59: 'vine snake', 62 | 60: 'night snake, Hypsiglena torquata', 63 | 61: 'boa constrictor, Constrictor constrictor', 64 | 62: 'rock python, rock snake, Python sebae', 65 | 63: 'Indian cobra, Naja naja', 66 | 64: 'green mamba', 67 | 65: 'sea snake', 68 | 66: 'horned viper, cerastes, sand viper, horned asp, Cerastes cornutus', 69 | 67: 'diamondback, diamondback rattlesnake, Crotalus adamanteus', 70 | 68: 'sidewinder, horned rattlesnake, Crotalus cerastes', 71 | 69: 'trilobite', 72 | 70: 'harvestman, daddy longlegs, Phalangium opilio', 73 | 71: 'scorpion', 74 | 72: 'black and gold garden spider, Argiope aurantia', 75 | 73: 'barn spider, Araneus cavaticus', 76 | 74: 'garden spider, Aranea diademata', 77 | 75: 'black widow, Latrodectus mactans', 78 | 76: 'tarantula', 79 | 77: 'wolf spider, hunting spider', 80 | 78: 'tick', 81 | 79: 'centipede', 82 | 80: 'black grouse', 83 | 81: 'ptarmigan', 84 | 82: 'ruffed grouse, partridge, Bonasa umbellus', 85 | 83: 'prairie chicken, prairie grouse, prairie fowl', 86 | 84: 'peacock', 87 | 85: 'quail', 88 | 86: 'partridge', 89 | 87: 'African grey, African gray, Psittacus erithacus', 90 | 88: 'macaw', 91 | 89: 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', 92 | 90: 'lorikeet', 93 | 91: 'coucal', 94 | 92: 'bee eater', 95 | 93: 'hornbill', 96 | 94: 'hummingbird', 97 | 95: 'jacamar', 98 | 96: 'toucan', 99 | 97: 'drake', 100 | 98: 'red-breasted merganser, Mergus serrator', 101 | 99: 'goose', 102 | 100: 'black swan, Cygnus atratus', 103 | 101: 'tusker', 104 | 102: 'echidna, spiny anteater, anteater', 105 | 103: 'platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus', 106 | 104: 'wallaby, brush kangaroo', 107 | 105: 'koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus', 108 | 106: 'wombat', 109 | 107: 'jellyfish', 110 | 108: 'sea anemone, anemone', 111 | 109: 'brain coral', 112 | 110: 'flatworm, platyhelminth', 113 | 111: 'nematode, nematode worm, roundworm', 114 | 112: 'conch', 115 | 113: 'snail', 116 | 114: 'slug', 117 | 115: 'sea slug, nudibranch', 118 | 116: 'chiton, coat-of-mail shell, sea cradle, polyplacophore', 119 | 117: 'chambered nautilus, pearly nautilus, nautilus', 120 | 118: 'Dungeness crab, Cancer magister', 121 | 119: 'rock crab, Cancer irroratus', 122 | 120: 'fiddler crab', 123 | 121: 'king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica', 124 | 122: 'American lobster, Northern lobster, Maine lobster, Homarus americanus', 125 | 123: 'spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish', 126 | 124: 'crayfish, crawfish, crawdad, crawdaddy', 127 | 125: 'hermit crab', 128 | 126: 'isopod', 129 | 127: 'white stork, Ciconia ciconia', 130 | 128: 'black stork, Ciconia nigra', 131 | 129: 'spoonbill', 132 | 130: 'flamingo', 133 | 131: 'little blue heron, Egretta caerulea', 134 | 132: 'American egret, great white heron, Egretta albus', 135 | 133: 'bittern', 136 | 134: 'crane', 137 | 135: 'limpkin, Aramus pictus', 138 | 136: 'European gallinule, Porphyrio porphyrio', 139 | 137: 'American coot, marsh hen, mud hen, water hen, Fulica americana', 140 | 138: 'bustard', 141 | 139: 'ruddy turnstone, Arenaria interpres', 142 | 140: 'red-backed sandpiper, dunlin, Erolia alpina', 143 | 141: 'redshank, Tringa totanus', 144 | 142: 'dowitcher', 145 | 143: 'oystercatcher, oyster catcher', 146 | 144: 'pelican', 147 | 145: 'king penguin, Aptenodytes patagonica', 148 | 146: 'albatross, mollymawk', 149 | 147: 'grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus', 150 | 148: 'killer whale, killer, orca, grampus, sea wolf, Orcinus orca', 151 | 149: 'dugong, Dugong dugon', 152 | 150: 'sea lion', 153 | 151: 'Chihuahua', 154 | 152: 'Japanese spaniel', 155 | 153: 'Maltese dog, Maltese terrier, Maltese', 156 | 154: 'Pekinese, Pekingese, Peke', 157 | 155: 'Shih-Tzu', 158 | 156: 'Blenheim spaniel', 159 | 157: 'papillon', 160 | 158: 'toy terrier', 161 | 159: 'Rhodesian ridgeback', 162 | 160: 'Afghan hound, Afghan', 163 | 161: 'basset, basset hound', 164 | 162: 'beagle', 165 | 163: 'bloodhound, sleuthhound', 166 | 164: 'bluetick', 167 | 165: 'black-and-tan coonhound', 168 | 166: 'Walker hound, Walker foxhound', 169 | 167: 'English foxhound', 170 | 168: 'redbone', 171 | 169: 'borzoi, Russian wolfhound', 172 | 170: 'Irish wolfhound', 173 | 171: 'Italian greyhound', 174 | 172: 'whippet', 175 | 173: 'Ibizan hound, Ibizan Podenco', 176 | 174: 'Norwegian elkhound, elkhound', 177 | 175: 'otterhound, otter hound', 178 | 176: 'Saluki, gazelle hound', 179 | 177: 'Scottish deerhound, deerhound', 180 | 178: 'Weimaraner', 181 | 179: 'Staffordshire bullterrier, Staffordshire bull terrier', 182 | 180: 'American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier', 183 | 181: 'Bedlington terrier', 184 | 182: 'Border terrier', 185 | 183: 'Kerry blue terrier', 186 | 184: 'Irish terrier', 187 | 185: 'Norfolk terrier', 188 | 186: 'Norwich terrier', 189 | 187: 'Yorkshire terrier', 190 | 188: 'wire-haired fox terrier', 191 | 189: 'Lakeland terrier', 192 | 190: 'Sealyham terrier, Sealyham', 193 | 191: 'Airedale, Airedale terrier', 194 | 192: 'cairn, cairn terrier', 195 | 193: 'Australian terrier', 196 | 194: 'Dandie Dinmont, Dandie Dinmont terrier', 197 | 195: 'Boston bull, Boston terrier', 198 | 196: 'miniature schnauzer', 199 | 197: 'giant schnauzer', 200 | 198: 'standard schnauzer', 201 | 199: 'Scotch terrier, Scottish terrier, Scottie', 202 | 200: 'Tibetan terrier, chrysanthemum dog', 203 | 201: 'silky terrier, Sydney silky', 204 | 202: 'soft-coated wheaten terrier', 205 | 203: 'West Highland white terrier', 206 | 204: 'Lhasa, Lhasa apso', 207 | 205: 'flat-coated retriever', 208 | 206: 'curly-coated retriever', 209 | 207: 'golden retriever', 210 | 208: 'Labrador retriever', 211 | 209: 'Chesapeake Bay retriever', 212 | 210: 'German short-haired pointer', 213 | 211: 'vizsla, Hungarian pointer', 214 | 212: 'English setter', 215 | 213: 'Irish setter, red setter', 216 | 214: 'Gordon setter', 217 | 215: 'Brittany spaniel', 218 | 216: 'clumber, clumber spaniel', 219 | 217: 'English springer, English springer spaniel', 220 | 218: 'Welsh springer spaniel', 221 | 219: 'cocker spaniel, English cocker spaniel, cocker', 222 | 220: 'Sussex spaniel', 223 | 221: 'Irish water spaniel', 224 | 222: 'kuvasz', 225 | 223: 'schipperke', 226 | 224: 'groenendael', 227 | 225: 'malinois', 228 | 226: 'briard', 229 | 227: 'kelpie', 230 | 228: 'komondor', 231 | 229: 'Old English sheepdog, bobtail', 232 | 230: 'Shetland sheepdog, Shetland sheep dog, Shetland', 233 | 231: 'collie', 234 | 232: 'Border collie', 235 | 233: 'Bouvier des Flandres, Bouviers des Flandres', 236 | 234: 'Rottweiler', 237 | 235: 'German shepherd, German shepherd dog, German police dog, alsatian', 238 | 236: 'Doberman, Doberman pinscher', 239 | 237: 'miniature pinscher', 240 | 238: 'Greater Swiss Mountain dog', 241 | 239: 'Bernese mountain dog', 242 | 240: 'Appenzeller', 243 | 241: 'EntleBucher', 244 | 242: 'boxer', 245 | 243: 'bull mastiff', 246 | 244: 'Tibetan mastiff', 247 | 245: 'French bulldog', 248 | 246: 'Great Dane', 249 | 247: 'Saint Bernard, St Bernard', 250 | 248: 'Eskimo dog, husky', 251 | 249: 'malamute, malemute, Alaskan malamute', 252 | 250: 'Siberian husky', 253 | 251: 'dalmatian, coach dog, carriage dog', 254 | 252: 'affenpinscher, monkey pinscher, monkey dog', 255 | 253: 'basenji', 256 | 254: 'pug, pug-dog', 257 | 255: 'Leonberg', 258 | 256: 'Newfoundland, Newfoundland dog', 259 | 257: 'Great Pyrenees', 260 | 258: 'Samoyed, Samoyede', 261 | 259: 'Pomeranian', 262 | 260: 'chow, chow chow', 263 | 261: 'keeshond', 264 | 262: 'Brabancon griffon', 265 | 263: 'Pembroke, Pembroke Welsh corgi', 266 | 264: 'Cardigan, Cardigan Welsh corgi', 267 | 265: 'toy poodle', 268 | 266: 'miniature poodle', 269 | 267: 'standard poodle', 270 | 268: 'Mexican hairless', 271 | 269: 'timber wolf, grey wolf, gray wolf, Canis lupus', 272 | 270: 'white wolf, Arctic wolf, Canis lupus tundrarum', 273 | 271: 'red wolf, maned wolf, Canis rufus, Canis niger', 274 | 272: 'coyote, prairie wolf, brush wolf, Canis latrans', 275 | 273: 'dingo, warrigal, warragal, Canis dingo', 276 | 274: 'dhole, Cuon alpinus', 277 | 275: 'African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus', 278 | 276: 'hyena, hyaena', 279 | 277: 'red fox, Vulpes vulpes', 280 | 278: 'kit fox, Vulpes macrotis', 281 | 279: 'Arctic fox, white fox, Alopex lagopus', 282 | 280: 'grey fox, gray fox, Urocyon cinereoargenteus', 283 | 281: 'tabby, tabby cat', 284 | 282: 'tiger cat', 285 | 283: 'Persian cat', 286 | 284: 'Siamese cat, Siamese', 287 | 285: 'Egyptian cat', 288 | 286: 'cougar, puma, catamount, mountain lion, painter, panther, Felis concolor', 289 | 287: 'lynx, catamount', 290 | 288: 'leopard, Panthera pardus', 291 | 289: 'snow leopard, ounce, Panthera uncia', 292 | 290: 'jaguar, panther, Panthera onca, Felis onca', 293 | 291: 'lion, king of beasts, Panthera leo', 294 | 292: 'tiger, Panthera tigris', 295 | 293: 'cheetah, chetah, Acinonyx jubatus', 296 | 294: 'brown bear, bruin, Ursus arctos', 297 | 295: 'American black bear, black bear, Ursus americanus, Euarctos americanus', 298 | 296: 'ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus', 299 | 297: 'sloth bear, Melursus ursinus, Ursus ursinus', 300 | 298: 'mongoose', 301 | 299: 'meerkat, mierkat', 302 | 300: 'tiger beetle', 303 | 301: 'ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle', 304 | 302: 'ground beetle, carabid beetle', 305 | 303: 'long-horned beetle, longicorn, longicorn beetle', 306 | 304: 'leaf beetle, chrysomelid', 307 | 305: 'dung beetle', 308 | 306: 'rhinoceros beetle', 309 | 307: 'weevil', 310 | 308: 'fly', 311 | 309: 'bee', 312 | 310: 'ant, emmet, pismire', 313 | 311: 'grasshopper, hopper', 314 | 312: 'cricket', 315 | 313: 'walking stick, walkingstick, stick insect', 316 | 314: 'cockroach, roach', 317 | 315: 'mantis, mantid', 318 | 316: 'cicada, cicala', 319 | 317: 'leafhopper', 320 | 318: 'lacewing, lacewing fly', 321 | 319: "dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk", 322 | 320: 'damselfly', 323 | 321: 'admiral', 324 | 322: 'ringlet, ringlet butterfly', 325 | 323: 'monarch, monarch butterfly, milkweed butterfly, Danaus plexippus', 326 | 324: 'cabbage butterfly', 327 | 325: 'sulphur butterfly, sulfur butterfly', 328 | 326: 'lycaenid, lycaenid butterfly', 329 | 327: 'starfish, sea star', 330 | 328: 'sea urchin', 331 | 329: 'sea cucumber, holothurian', 332 | 330: 'wood rabbit, cottontail, cottontail rabbit', 333 | 331: 'hare', 334 | 332: 'Angora, Angora rabbit', 335 | 333: 'hamster', 336 | 334: 'porcupine, hedgehog', 337 | 335: 'fox squirrel, eastern fox squirrel, Sciurus niger', 338 | 336: 'marmot', 339 | 337: 'beaver', 340 | 338: 'guinea pig, Cavia cobaya', 341 | 339: 'sorrel', 342 | 340: 'zebra', 343 | 341: 'hog, pig, grunter, squealer, Sus scrofa', 344 | 342: 'wild boar, boar, Sus scrofa', 345 | 343: 'warthog', 346 | 344: 'hippopotamus, hippo, river horse, Hippopotamus amphibius', 347 | 345: 'ox', 348 | 346: 'water buffalo, water ox, Asiatic buffalo, Bubalus bubalis', 349 | 347: 'bison', 350 | 348: 'ram, tup', 351 | 349: 'bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis', 352 | 350: 'ibex, Capra ibex', 353 | 351: 'hartebeest', 354 | 352: 'impala, Aepyceros melampus', 355 | 353: 'gazelle', 356 | 354: 'Arabian camel, dromedary, Camelus dromedarius', 357 | 355: 'llama', 358 | 356: 'weasel', 359 | 357: 'mink', 360 | 358: 'polecat, fitch, foulmart, foumart, Mustela putorius', 361 | 359: 'black-footed ferret, ferret, Mustela nigripes', 362 | 360: 'otter', 363 | 361: 'skunk, polecat, wood pussy', 364 | 362: 'badger', 365 | 363: 'armadillo', 366 | 364: 'three-toed sloth, ai, Bradypus tridactylus', 367 | 365: 'orangutan, orang, orangutang, Pongo pygmaeus', 368 | 366: 'gorilla, Gorilla gorilla', 369 | 367: 'chimpanzee, chimp, Pan troglodytes', 370 | 368: 'gibbon, Hylobates lar', 371 | 369: 'siamang, Hylobates syndactylus, Symphalangus syndactylus', 372 | 370: 'guenon, guenon monkey', 373 | 371: 'patas, hussar monkey, Erythrocebus patas', 374 | 372: 'baboon', 375 | 373: 'macaque', 376 | 374: 'langur', 377 | 375: 'colobus, colobus monkey', 378 | 376: 'proboscis monkey, Nasalis larvatus', 379 | 377: 'marmoset', 380 | 378: 'capuchin, ringtail, Cebus capucinus', 381 | 379: 'howler monkey, howler', 382 | 380: 'titi, titi monkey', 383 | 381: 'spider monkey, Ateles geoffroyi', 384 | 382: 'squirrel monkey, Saimiri sciureus', 385 | 383: 'Madagascar cat, ring-tailed lemur, Lemur catta', 386 | 384: 'indri, indris, Indri indri, Indri brevicaudatus', 387 | 385: 'Indian elephant, Elephas maximus', 388 | 386: 'African elephant, Loxodonta africana', 389 | 387: 'lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens', 390 | 388: 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', 391 | 389: 'barracouta, snoek', 392 | 390: 'eel', 393 | 391: 'coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch', 394 | 392: 'rock beauty, Holocanthus tricolor', 395 | 393: 'anemone fish', 396 | 394: 'sturgeon', 397 | 395: 'gar, garfish, garpike, billfish, Lepisosteus osseus', 398 | 396: 'lionfish', 399 | 397: 'puffer, pufferfish, blowfish, globefish', 400 | 398: 'abacus', 401 | 399: 'abaya', 402 | 400: "academic gown, academic robe, judge's robe", 403 | 401: 'accordion, piano accordion, squeeze box', 404 | 402: 'acoustic guitar', 405 | 403: 'aircraft carrier, carrier, flattop, attack aircraft carrier', 406 | 404: 'airliner', 407 | 405: 'airship, dirigible', 408 | 406: 'altar', 409 | 407: 'ambulance', 410 | 408: 'amphibian, amphibious vehicle', 411 | 409: 'analog clock', 412 | 410: 'apiary, bee house', 413 | 411: 'apron', 414 | 412: 'ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin', 415 | 413: 'assault rifle, assault gun', 416 | 414: 'backpack, back pack, knapsack, packsack, rucksack, haversack', 417 | 415: 'bakery, bakeshop, bakehouse', 418 | 416: 'balance beam, beam', 419 | 417: 'balloon', 420 | 418: 'ballpoint, ballpoint pen, ballpen, Biro', 421 | 419: 'Band Aid', 422 | 420: 'banjo', 423 | 421: 'bannister, banister, balustrade, balusters, handrail', 424 | 422: 'barbell', 425 | 423: 'barber chair', 426 | 424: 'barbershop', 427 | 425: 'barn', 428 | 426: 'barometer', 429 | 427: 'barrel, cask', 430 | 428: 'barrow, garden cart, lawn cart, wheelbarrow', 431 | 429: 'baseball', 432 | 430: 'basketball', 433 | 431: 'bassinet', 434 | 432: 'bassoon', 435 | 433: 'bathing cap, swimming cap', 436 | 434: 'bath towel', 437 | 435: 'bathtub, bathing tub, bath, tub', 438 | 436: 'beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon', 439 | 437: 'beacon, lighthouse, beacon light, pharos', 440 | 438: 'beaker', 441 | 439: 'bearskin, busby, shako', 442 | 440: 'beer bottle', 443 | 441: 'beer glass', 444 | 442: 'bell cote, bell cot', 445 | 443: 'bib', 446 | 444: 'bicycle-built-for-two, tandem bicycle, tandem', 447 | 445: 'bikini, two-piece', 448 | 446: 'binder, ring-binder', 449 | 447: 'binoculars, field glasses, opera glasses', 450 | 448: 'birdhouse', 451 | 449: 'boathouse', 452 | 450: 'bobsled, bobsleigh, bob', 453 | 451: 'bolo tie, bolo, bola tie, bola', 454 | 452: 'bonnet, poke bonnet', 455 | 453: 'bookcase', 456 | 454: 'bookshop, bookstore, bookstall', 457 | 455: 'bottlecap', 458 | 456: 'bow', 459 | 457: 'bow tie, bow-tie, bowtie', 460 | 458: 'brass, memorial tablet, plaque', 461 | 459: 'brassiere, bra, bandeau', 462 | 460: 'breakwater, groin, groyne, mole, bulwark, seawall, jetty', 463 | 461: 'breastplate, aegis, egis', 464 | 462: 'broom', 465 | 463: 'bucket, pail', 466 | 464: 'buckle', 467 | 465: 'bulletproof vest', 468 | 466: 'bullet train, bullet', 469 | 467: 'butcher shop, meat market', 470 | 468: 'cab, hack, taxi, taxicab', 471 | 469: 'caldron, cauldron', 472 | 470: 'candle, taper, wax light', 473 | 471: 'cannon', 474 | 472: 'canoe', 475 | 473: 'can opener, tin opener', 476 | 474: 'cardigan', 477 | 475: 'car mirror', 478 | 476: 'carousel, carrousel, merry-go-round, roundabout, whirligig', 479 | 477: "carpenter's kit, tool kit", 480 | 478: 'carton', 481 | 479: 'car wheel', 482 | 480: 'cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM', 483 | 481: 'cassette', 484 | 482: 'cassette player', 485 | 483: 'castle', 486 | 484: 'catamaran', 487 | 485: 'CD player', 488 | 486: 'cello, violoncello', 489 | 487: 'cellular telephone, cellular phone, cellphone, cell, mobile phone', 490 | 488: 'chain', 491 | 489: 'chainlink fence', 492 | 490: 'chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour', 493 | 491: 'chain saw, chainsaw', 494 | 492: 'chest', 495 | 493: 'chiffonier, commode', 496 | 494: 'chime, bell, gong', 497 | 495: 'china cabinet, china closet', 498 | 496: 'Christmas stocking', 499 | 497: 'church, church building', 500 | 498: 'cinema, movie theater, movie theatre, movie house, picture palace', 501 | 499: 'cleaver, meat cleaver, chopper', 502 | 500: 'cliff dwelling', 503 | 501: 'cloak', 504 | 502: 'clog, geta, patten, sabot', 505 | 503: 'cocktail shaker', 506 | 504: 'coffee mug', 507 | 505: 'coffeepot', 508 | 506: 'coil, spiral, volute, whorl, helix', 509 | 507: 'combination lock', 510 | 508: 'computer keyboard, keypad', 511 | 509: 'confectionery, confectionary, candy store', 512 | 510: 'container ship, containership, container vessel', 513 | 511: 'convertible', 514 | 512: 'corkscrew, bottle screw', 515 | 513: 'cornet, horn, trumpet, trump', 516 | 514: 'cowboy boot', 517 | 515: 'cowboy hat, ten-gallon hat', 518 | 516: 'cradle', 519 | 517: 'crane', 520 | 518: 'crash helmet', 521 | 519: 'crate', 522 | 520: 'crib, cot', 523 | 521: 'Crock Pot', 524 | 522: 'croquet ball', 525 | 523: 'crutch', 526 | 524: 'cuirass', 527 | 525: 'dam, dike, dyke', 528 | 526: 'desk', 529 | 527: 'desktop computer', 530 | 528: 'dial telephone, dial phone', 531 | 529: 'diaper, nappy, napkin', 532 | 530: 'digital clock', 533 | 531: 'digital watch', 534 | 532: 'dining table, board', 535 | 533: 'dishrag, dishcloth', 536 | 534: 'dishwasher, dish washer, dishwashing machine', 537 | 535: 'disk brake, disc brake', 538 | 536: 'dock, dockage, docking facility', 539 | 537: 'dogsled, dog sled, dog sleigh', 540 | 538: 'dome', 541 | 539: 'doormat, welcome mat', 542 | 540: 'drilling platform, offshore rig', 543 | 541: 'drum, membranophone, tympan', 544 | 542: 'drumstick', 545 | 543: 'dumbbell', 546 | 544: 'Dutch oven', 547 | 545: 'electric fan, blower', 548 | 546: 'electric guitar', 549 | 547: 'electric locomotive', 550 | 548: 'entertainment center', 551 | 549: 'envelope', 552 | 550: 'espresso maker', 553 | 551: 'face powder', 554 | 552: 'feather boa, boa', 555 | 553: 'file, file cabinet, filing cabinet', 556 | 554: 'fireboat', 557 | 555: 'fire engine, fire truck', 558 | 556: 'fire screen, fireguard', 559 | 557: 'flagpole, flagstaff', 560 | 558: 'flute, transverse flute', 561 | 559: 'folding chair', 562 | 560: 'football helmet', 563 | 561: 'forklift', 564 | 562: 'fountain', 565 | 563: 'fountain pen', 566 | 564: 'four-poster', 567 | 565: 'freight car', 568 | 566: 'French horn, horn', 569 | 567: 'frying pan, frypan, skillet', 570 | 568: 'fur coat', 571 | 569: 'garbage truck, dustcart', 572 | 570: 'gasmask, respirator, gas helmet', 573 | 571: 'gas pump, gasoline pump, petrol pump, island dispenser', 574 | 572: 'goblet', 575 | 573: 'go-kart', 576 | 574: 'golf ball', 577 | 575: 'golfcart, golf cart', 578 | 576: 'gondola', 579 | 577: 'gong, tam-tam', 580 | 578: 'gown', 581 | 579: 'grand piano, grand', 582 | 580: 'greenhouse, nursery, glasshouse', 583 | 581: 'grille, radiator grille', 584 | 582: 'grocery store, grocery, food market, market', 585 | 583: 'guillotine', 586 | 584: 'hair slide', 587 | 585: 'hair spray', 588 | 586: 'half track', 589 | 587: 'hammer', 590 | 588: 'hamper', 591 | 589: 'hand blower, blow dryer, blow drier, hair dryer, hair drier', 592 | 590: 'hand-held computer, hand-held microcomputer', 593 | 591: 'handkerchief, hankie, hanky, hankey', 594 | 592: 'hard disc, hard disk, fixed disk', 595 | 593: 'harmonica, mouth organ, harp, mouth harp', 596 | 594: 'harp', 597 | 595: 'harvester, reaper', 598 | 596: 'hatchet', 599 | 597: 'holster', 600 | 598: 'home theater, home theatre', 601 | 599: 'honeycomb', 602 | 600: 'hook, claw', 603 | 601: 'hoopskirt, crinoline', 604 | 602: 'horizontal bar, high bar', 605 | 603: 'horse cart, horse-cart', 606 | 604: 'hourglass', 607 | 605: 'iPod', 608 | 606: 'iron, smoothing iron', 609 | 607: "jack-o'-lantern", 610 | 608: 'jean, blue jean, denim', 611 | 609: 'jeep, landrover', 612 | 610: 'jersey, T-shirt, tee shirt', 613 | 611: 'jigsaw puzzle', 614 | 612: 'jinrikisha, ricksha, rickshaw', 615 | 613: 'joystick', 616 | 614: 'kimono', 617 | 615: 'knee pad', 618 | 616: 'knot', 619 | 617: 'lab coat, laboratory coat', 620 | 618: 'ladle', 621 | 619: 'lampshade, lamp shade', 622 | 620: 'laptop, laptop computer', 623 | 621: 'lawn mower, mower', 624 | 622: 'lens cap, lens cover', 625 | 623: 'letter opener, paper knife, paperknife', 626 | 624: 'library', 627 | 625: 'lifeboat', 628 | 626: 'lighter, light, igniter, ignitor', 629 | 627: 'limousine, limo', 630 | 628: 'liner, ocean liner', 631 | 629: 'lipstick, lip rouge', 632 | 630: 'Loafer', 633 | 631: 'lotion', 634 | 632: 'loudspeaker, speaker, speaker unit, loudspeaker system, speaker system', 635 | 633: "loupe, jeweler's loupe", 636 | 634: 'lumbermill, sawmill', 637 | 635: 'magnetic compass', 638 | 636: 'mailbag, postbag', 639 | 637: 'mailbox, letter box', 640 | 638: 'maillot', 641 | 639: 'maillot, tank suit', 642 | 640: 'manhole cover', 643 | 641: 'maraca', 644 | 642: 'marimba, xylophone', 645 | 643: 'mask', 646 | 644: 'matchstick', 647 | 645: 'maypole', 648 | 646: 'maze, labyrinth', 649 | 647: 'measuring cup', 650 | 648: 'medicine chest, medicine cabinet', 651 | 649: 'megalith, megalithic structure', 652 | 650: 'microphone, mike', 653 | 651: 'microwave, microwave oven', 654 | 652: 'military uniform', 655 | 653: 'milk can', 656 | 654: 'minibus', 657 | 655: 'miniskirt, mini', 658 | 656: 'minivan', 659 | 657: 'missile', 660 | 658: 'mitten', 661 | 659: 'mixing bowl', 662 | 660: 'mobile home, manufactured home', 663 | 661: 'Model T', 664 | 662: 'modem', 665 | 663: 'monastery', 666 | 664: 'monitor', 667 | 665: 'moped', 668 | 666: 'mortar', 669 | 667: 'mortarboard', 670 | 668: 'mosque', 671 | 669: 'mosquito net', 672 | 670: 'motor scooter, scooter', 673 | 671: 'mountain bike, all-terrain bike, off-roader', 674 | 672: 'mountain tent', 675 | 673: 'mouse, computer mouse', 676 | 674: 'mousetrap', 677 | 675: 'moving van', 678 | 676: 'muzzle', 679 | 677: 'nail', 680 | 678: 'neck brace', 681 | 679: 'necklace', 682 | 680: 'nipple', 683 | 681: 'notebook, notebook computer', 684 | 682: 'obelisk', 685 | 683: 'oboe, hautboy, hautbois', 686 | 684: 'ocarina, sweet potato', 687 | 685: 'odometer, hodometer, mileometer, milometer', 688 | 686: 'oil filter', 689 | 687: 'organ, pipe organ', 690 | 688: 'oscilloscope, scope, cathode-ray oscilloscope, CRO', 691 | 689: 'overskirt', 692 | 690: 'oxcart', 693 | 691: 'oxygen mask', 694 | 692: 'packet', 695 | 693: 'paddle, boat paddle', 696 | 694: 'paddlewheel, paddle wheel', 697 | 695: 'padlock', 698 | 696: 'paintbrush', 699 | 697: "pajama, pyjama, pj's, jammies", 700 | 698: 'palace', 701 | 699: 'panpipe, pandean pipe, syrinx', 702 | 700: 'paper towel', 703 | 701: 'parachute, chute', 704 | 702: 'parallel bars, bars', 705 | 703: 'park bench', 706 | 704: 'parking meter', 707 | 705: 'passenger car, coach, carriage', 708 | 706: 'patio, terrace', 709 | 707: 'pay-phone, pay-station', 710 | 708: 'pedestal, plinth, footstall', 711 | 709: 'pencil box, pencil case', 712 | 710: 'pencil sharpener', 713 | 711: 'perfume, essence', 714 | 712: 'Petri dish', 715 | 713: 'photocopier', 716 | 714: 'pick, plectrum, plectron', 717 | 715: 'pickelhaube', 718 | 716: 'picket fence, paling', 719 | 717: 'pickup, pickup truck', 720 | 718: 'pier', 721 | 719: 'piggy bank, penny bank', 722 | 720: 'pill bottle', 723 | 721: 'pillow', 724 | 722: 'ping-pong ball', 725 | 723: 'pinwheel', 726 | 724: 'pirate, pirate ship', 727 | 725: 'pitcher, ewer', 728 | 726: "plane, carpenter's plane, woodworking plane", 729 | 727: 'planetarium', 730 | 728: 'plastic bag', 731 | 729: 'plate rack', 732 | 730: 'plow, plough', 733 | 731: "plunger, plumber's helper", 734 | 732: 'Polaroid camera, Polaroid Land camera', 735 | 733: 'pole', 736 | 734: 'police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria', 737 | 735: 'poncho', 738 | 736: 'pool table, billiard table, snooker table', 739 | 737: 'pop bottle, soda bottle', 740 | 738: 'pot, flowerpot', 741 | 739: "potter's wheel", 742 | 740: 'power drill', 743 | 741: 'prayer rug, prayer mat', 744 | 742: 'printer', 745 | 743: 'prison, prison house', 746 | 744: 'projectile, missile', 747 | 745: 'projector', 748 | 746: 'puck, hockey puck', 749 | 747: 'punching bag, punch bag, punching ball, punchball', 750 | 748: 'purse', 751 | 749: 'quill, quill pen', 752 | 750: 'quilt, comforter, comfort, puff', 753 | 751: 'racer, race car, racing car', 754 | 752: 'racket, racquet', 755 | 753: 'radiator', 756 | 754: 'radio, wireless', 757 | 755: 'radio telescope, radio reflector', 758 | 756: 'rain barrel', 759 | 757: 'recreational vehicle, RV, R.V.', 760 | 758: 'reel', 761 | 759: 'reflex camera', 762 | 760: 'refrigerator, icebox', 763 | 761: 'remote control, remote', 764 | 762: 'restaurant, eating house, eating place, eatery', 765 | 763: 'revolver, six-gun, six-shooter', 766 | 764: 'rifle', 767 | 765: 'rocking chair, rocker', 768 | 766: 'rotisserie', 769 | 767: 'rubber eraser, rubber, pencil eraser', 770 | 768: 'rugby ball', 771 | 769: 'rule, ruler', 772 | 770: 'running shoe', 773 | 771: 'safe', 774 | 772: 'safety pin', 775 | 773: 'saltshaker, salt shaker', 776 | 774: 'sandal', 777 | 775: 'sarong', 778 | 776: 'sax, saxophone', 779 | 777: 'scabbard', 780 | 778: 'scale, weighing machine', 781 | 779: 'school bus', 782 | 780: 'schooner', 783 | 781: 'scoreboard', 784 | 782: 'screen, CRT screen', 785 | 783: 'screw', 786 | 784: 'screwdriver', 787 | 785: 'seat belt, seatbelt', 788 | 786: 'sewing machine', 789 | 787: 'shield, buckler', 790 | 788: 'shoe shop, shoe-shop, shoe store', 791 | 789: 'shoji', 792 | 790: 'shopping basket', 793 | 791: 'shopping cart', 794 | 792: 'shovel', 795 | 793: 'shower cap', 796 | 794: 'shower curtain', 797 | 795: 'ski', 798 | 796: 'ski mask', 799 | 797: 'sleeping bag', 800 | 798: 'slide rule, slipstick', 801 | 799: 'sliding door', 802 | 800: 'slot, one-armed bandit', 803 | 801: 'snorkel', 804 | 802: 'snowmobile', 805 | 803: 'snowplow, snowplough', 806 | 804: 'soap dispenser', 807 | 805: 'soccer ball', 808 | 806: 'sock', 809 | 807: 'solar dish, solar collector, solar furnace', 810 | 808: 'sombrero', 811 | 809: 'soup bowl', 812 | 810: 'space bar', 813 | 811: 'space heater', 814 | 812: 'space shuttle', 815 | 813: 'spatula', 816 | 814: 'speedboat', 817 | 815: "spider web, spider's web", 818 | 816: 'spindle', 819 | 817: 'sports car, sport car', 820 | 818: 'spotlight, spot', 821 | 819: 'stage', 822 | 820: 'steam locomotive', 823 | 821: 'steel arch bridge', 824 | 822: 'steel drum', 825 | 823: 'stethoscope', 826 | 824: 'stole', 827 | 825: 'stone wall', 828 | 826: 'stopwatch, stop watch', 829 | 827: 'stove', 830 | 828: 'strainer', 831 | 829: 'streetcar, tram, tramcar, trolley, trolley car', 832 | 830: 'stretcher', 833 | 831: 'studio couch, day bed', 834 | 832: 'stupa, tope', 835 | 833: 'submarine, pigboat, sub, U-boat', 836 | 834: 'suit, suit of clothes', 837 | 835: 'sundial', 838 | 836: 'sunglass', 839 | 837: 'sunglasses, dark glasses, shades', 840 | 838: 'sunscreen, sunblock, sun blocker', 841 | 839: 'suspension bridge', 842 | 840: 'swab, swob, mop', 843 | 841: 'sweatshirt', 844 | 842: 'swimming trunks, bathing trunks', 845 | 843: 'swing', 846 | 844: 'switch, electric switch, electrical switch', 847 | 845: 'syringe', 848 | 846: 'table lamp', 849 | 847: 'tank, army tank, armored combat vehicle, armoured combat vehicle', 850 | 848: 'tape player', 851 | 849: 'teapot', 852 | 850: 'teddy, teddy bear', 853 | 851: 'television, television system', 854 | 852: 'tennis ball', 855 | 853: 'thatch, thatched roof', 856 | 854: 'theater curtain, theatre curtain', 857 | 855: 'thimble', 858 | 856: 'thresher, thrasher, threshing machine', 859 | 857: 'throne', 860 | 858: 'tile roof', 861 | 859: 'toaster', 862 | 860: 'tobacco shop, tobacconist shop, tobacconist', 863 | 861: 'toilet seat', 864 | 862: 'torch', 865 | 863: 'totem pole', 866 | 864: 'tow truck, tow car, wrecker', 867 | 865: 'toyshop', 868 | 866: 'tractor', 869 | 867: 'trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi', 870 | 868: 'tray', 871 | 869: 'trench coat', 872 | 870: 'tricycle, trike, velocipede', 873 | 871: 'trimaran', 874 | 872: 'tripod', 875 | 873: 'triumphal arch', 876 | 874: 'trolleybus, trolley coach, trackless trolley', 877 | 875: 'trombone', 878 | 876: 'tub, vat', 879 | 877: 'turnstile', 880 | 878: 'typewriter keyboard', 881 | 879: 'umbrella', 882 | 880: 'unicycle, monocycle', 883 | 881: 'upright, upright piano', 884 | 882: 'vacuum, vacuum cleaner', 885 | 883: 'vase', 886 | 884: 'vault', 887 | 885: 'velvet', 888 | 886: 'vending machine', 889 | 887: 'vestment', 890 | 888: 'viaduct', 891 | 889: 'violin, fiddle', 892 | 890: 'volleyball', 893 | 891: 'waffle iron', 894 | 892: 'wall clock', 895 | 893: 'wallet, billfold, notecase, pocketbook', 896 | 894: 'wardrobe, closet, press', 897 | 895: 'warplane, military plane', 898 | 896: 'washbasin, handbasin, washbowl, lavabo, wash-hand basin', 899 | 897: 'washer, automatic washer, washing machine', 900 | 898: 'water bottle', 901 | 899: 'water jug', 902 | 900: 'water tower', 903 | 901: 'whiskey jug', 904 | 902: 'whistle', 905 | 903: 'wig', 906 | 904: 'window screen', 907 | 905: 'window shade', 908 | 906: 'Windsor tie', 909 | 907: 'wine bottle', 910 | 908: 'wing', 911 | 909: 'wok', 912 | 910: 'wooden spoon', 913 | 911: 'wool, woolen, woollen', 914 | 912: 'worm fence, snake fence, snake-rail fence, Virginia fence', 915 | 913: 'wreck', 916 | 914: 'yawl', 917 | 915: 'yurt', 918 | 916: 'web site, website, internet site, site', 919 | 917: 'comic book', 920 | 918: 'crossword puzzle, crossword', 921 | 919: 'street sign', 922 | 920: 'traffic light, traffic signal, stoplight', 923 | 921: 'book jacket, dust cover, dust jacket, dust wrapper', 924 | 922: 'menu', 925 | 923: 'plate', 926 | 924: 'guacamole', 927 | 925: 'consomme', 928 | 926: 'hot pot, hotpot', 929 | 927: 'trifle', 930 | 928: 'ice cream, icecream', 931 | 929: 'ice lolly, lolly, lollipop, popsicle', 932 | 930: 'French loaf', 933 | 931: 'bagel, beigel', 934 | 932: 'pretzel', 935 | 933: 'cheeseburger', 936 | 934: 'hotdog, hot dog, red hot', 937 | 935: 'mashed potato', 938 | 936: 'head cabbage', 939 | 937: 'broccoli', 940 | 938: 'cauliflower', 941 | 939: 'zucchini, courgette', 942 | 940: 'spaghetti squash', 943 | 941: 'acorn squash', 944 | 942: 'butternut squash', 945 | 943: 'cucumber, cuke', 946 | 944: 'artichoke, globe artichoke', 947 | 945: 'bell pepper', 948 | 946: 'cardoon', 949 | 947: 'mushroom', 950 | 948: 'Granny Smith', 951 | 949: 'strawberry', 952 | 950: 'orange', 953 | 951: 'lemon', 954 | 952: 'fig', 955 | 953: 'pineapple, ananas', 956 | 954: 'banana', 957 | 955: 'jackfruit, jak, jack', 958 | 956: 'custard apple', 959 | 957: 'pomegranate', 960 | 958: 'hay', 961 | 959: 'carbonara', 962 | 960: 'chocolate sauce, chocolate syrup', 963 | 961: 'dough', 964 | 962: 'meat loaf, meatloaf', 965 | 963: 'pizza, pizza pie', 966 | 964: 'potpie', 967 | 965: 'burrito', 968 | 966: 'red wine', 969 | 967: 'espresso', 970 | 968: 'cup', 971 | 969: 'eggnog', 972 | 970: 'alp', 973 | 971: 'bubble', 974 | 972: 'cliff, drop, drop-off', 975 | 973: 'coral reef', 976 | 974: 'geyser', 977 | 975: 'lakeside, lakeshore', 978 | 976: 'promontory, headland, head, foreland', 979 | 977: 'sandbar, sand bar', 980 | 978: 'seashore, coast, seacoast, sea-coast', 981 | 979: 'valley, vale', 982 | 980: 'volcano', 983 | 981: 'ballplayer, baseball player', 984 | 982: 'groom, bridegroom', 985 | 983: 'scuba diver', 986 | 984: 'rapeseed', 987 | 985: 'daisy', 988 | 986: "yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum", 989 | 987: 'corn', 990 | 988: 'acorn', 991 | 989: 'hip, rose hip, rosehip', 992 | 990: 'buckeye, horse chestnut, conker', 993 | 991: 'coral fungus', 994 | 992: 'agaric', 995 | 993: 'gyromitra', 996 | 994: 'stinkhorn, carrion fungus', 997 | 995: 'earthstar', 998 | 996: 'hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa', 999 | 997: 'bolete', 1000 | 998: 'ear, spike, capitulum', 1001 | 999: 'toilet tissue, toilet paper, bathroom tissue' 1002 | } -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/validation_utils/convert_ground_truth_labels/convert_ground_truth_labels.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Copyright 2017 Kent Sommer 3 | 4 | Licensed under the Apache License, Version 2.0 (the "License"); 5 | you may not use this file except in compliance with the License. 6 | You may obtain a copy of the License at 7 | 8 | http://www.apache.org/licenses/LICENSE-2.0 9 | 10 | Unless required by applicable law or agreed to in writing, software 11 | distributed under the License is distributed on an "AS IS" BASIS, 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | See the License for the specific language governing permissions and 14 | limitations under the License. 15 | ''' 16 | classes = eval(open('correct_classes.txt', 'r').read()) 17 | correct_classes = {} 18 | old_classes = {} 19 | 20 | correct_labels = [] 21 | 22 | lines = open('old_classes_raw.txt').read().splitlines() 23 | 24 | for line in lines: 25 | _, uid, name = line.split() 26 | name = name.replace("_", " ") 27 | name = name.lower() 28 | uid = int(uid) 29 | old_classes[uid] = name 30 | 31 | for key, value in classes.iteritems(): 32 | uid = key 33 | name = value.split(",")[0] 34 | name = name.lower() 35 | correct_classes[name] = uid 36 | 37 | lines = open('val_ground_truth_labels.txt').read().splitlines() 38 | 39 | for line in lines: 40 | key = int(line) 41 | name = old_classes[key] 42 | new_label = correct_classes[name] 43 | print("Old label was: ", key, ". New label is: ", new_label) 44 | correct_labels.append(new_label) 45 | 46 | print("Total labels = ", len(correct_labels)) 47 | 48 | f=open('../GTL.txt','w') 49 | for label in correct_labels: 50 | f.write(str(label)+'\n') 51 | f.close() 52 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/validation_utils/convert_ground_truth_labels/correct_classes.txt: -------------------------------------------------------------------------------- 1 | {0: 'tench, Tinca tinca', 2 | 1: 'goldfish, Carassius auratus', 3 | 2: 'great white shark, white shark, man-eater, man-eating shark, Carcharodon carcharias', 4 | 3: 'tiger shark, Galeocerdo cuvieri', 5 | 4: 'hammerhead, hammerhead shark', 6 | 5: 'electric ray, crampfish, numbfish, torpedo', 7 | 6: 'stingray', 8 | 7: 'cock', 9 | 8: 'hen', 10 | 9: 'ostrich, Struthio camelus', 11 | 10: 'brambling, Fringilla montifringilla', 12 | 11: 'goldfinch, Carduelis carduelis', 13 | 12: 'house finch, linnet, Carpodacus mexicanus', 14 | 13: 'junco, snowbird', 15 | 14: 'indigo bunting, indigo finch, indigo bird, Passerina cyanea', 16 | 15: 'robin, American robin, Turdus migratorius', 17 | 16: 'bulbul', 18 | 17: 'jay', 19 | 18: 'magpie', 20 | 19: 'chickadee', 21 | 20: 'water ouzel, dipper', 22 | 21: 'kite', 23 | 22: 'bald eagle, American eagle, Haliaeetus leucocephalus', 24 | 23: 'vulture', 25 | 24: 'great grey owl, great gray owl, Strix nebulosa', 26 | 25: 'European fire salamander, Salamandra salamandra', 27 | 26: 'common newt, Triturus vulgaris', 28 | 27: 'eft', 29 | 28: 'spotted salamander, Ambystoma maculatum', 30 | 29: 'axolotl, mud puppy, Ambystoma mexicanum', 31 | 30: 'bullfrog, Rana catesbeiana', 32 | 31: 'tree frog, tree-frog', 33 | 32: 'tailed frog, bell toad, ribbed toad, tailed toad, Ascaphus trui', 34 | 33: 'loggerhead, loggerhead turtle, Caretta caretta', 35 | 34: 'leatherback turtle, leatherback, leathery turtle, Dermochelys coriacea', 36 | 35: 'mud turtle', 37 | 36: 'terrapin', 38 | 37: 'box turtle, box tortoise', 39 | 38: 'banded gecko', 40 | 39: 'common iguana, iguana, Iguana iguana', 41 | 40: 'American chameleon, anole, Anolis carolinensis', 42 | 41: 'whiptail, whiptail lizard', 43 | 42: 'agama', 44 | 43: 'frilled lizard, Chlamydosaurus kingi', 45 | 44: 'alligator lizard', 46 | 45: 'Gila monster, Heloderma suspectum', 47 | 46: 'green lizard, Lacerta viridis', 48 | 47: 'African chameleon, Chamaeleo chamaeleon', 49 | 48: 'Komodo dragon, Komodo lizard, dragon lizard, giant lizard, Varanus komodoensis', 50 | 49: 'African crocodile, Nile crocodile, Crocodylus niloticus', 51 | 50: 'American alligator, Alligator mississipiensis', 52 | 51: 'triceratops', 53 | 52: 'thunder snake, worm snake, Carphophis amoenus', 54 | 53: 'ringneck snake, ring-necked snake, ring snake', 55 | 54: 'hognose snake, puff adder, sand viper', 56 | 55: 'green snake, grass snake', 57 | 56: 'king snake, kingsnake', 58 | 57: 'garter snake, grass snake', 59 | 58: 'water snake', 60 | 59: 'vine snake', 61 | 60: 'night snake, Hypsiglena torquata', 62 | 61: 'boa constrictor, Constrictor constrictor', 63 | 62: 'rock python, rock snake, Python sebae', 64 | 63: 'Indian cobra, Naja naja', 65 | 64: 'green mamba', 66 | 65: 'sea snake', 67 | 66: 'horned viper, cerastes, sand viper, horned asp, Cerastes cornutus', 68 | 67: 'diamondback, diamondback rattlesnake, Crotalus adamanteus', 69 | 68: 'sidewinder, horned rattlesnake, Crotalus cerastes', 70 | 69: 'trilobite', 71 | 70: 'harvestman, daddy longlegs, Phalangium opilio', 72 | 71: 'scorpion', 73 | 72: 'black and gold garden spider, Argiope aurantia', 74 | 73: 'barn spider, Araneus cavaticus', 75 | 74: 'garden spider, Aranea diademata', 76 | 75: 'black widow, Latrodectus mactans', 77 | 76: 'tarantula', 78 | 77: 'wolf spider, hunting spider', 79 | 78: 'tick', 80 | 79: 'centipede', 81 | 80: 'black grouse', 82 | 81: 'ptarmigan', 83 | 82: 'ruffed grouse, partridge, Bonasa umbellus', 84 | 83: 'prairie chicken, prairie grouse, prairie fowl', 85 | 84: 'peacock', 86 | 85: 'quail', 87 | 86: 'partridge', 88 | 87: 'African grey, African gray, Psittacus erithacus', 89 | 88: 'macaw', 90 | 89: 'sulphur-crested cockatoo, Kakatoe galerita, Cacatua galerita', 91 | 90: 'lorikeet', 92 | 91: 'coucal', 93 | 92: 'bee eater', 94 | 93: 'hornbill', 95 | 94: 'hummingbird', 96 | 95: 'jacamar', 97 | 96: 'toucan', 98 | 97: 'drake', 99 | 98: 'red-breasted merganser, Mergus serrator', 100 | 99: 'goose', 101 | 100: 'black swan, Cygnus atratus', 102 | 101: 'tusker', 103 | 102: 'echidna, spiny anteater, anteater', 104 | 103: 'platypus, duckbill, duckbilled platypus, duck-billed platypus, Ornithorhynchus anatinus', 105 | 104: 'wallaby, brush kangaroo', 106 | 105: 'koala, koala bear, kangaroo bear, native bear, Phascolarctos cinereus', 107 | 106: 'wombat', 108 | 107: 'jellyfish', 109 | 108: 'sea anemone, anemone', 110 | 109: 'brain coral', 111 | 110: 'flatworm, platyhelminth', 112 | 111: 'nematode, nematode worm, roundworm', 113 | 112: 'conch', 114 | 113: 'snail', 115 | 114: 'slug', 116 | 115: 'sea slug, nudibranch', 117 | 116: 'chiton, coat-of-mail shell, sea cradle, polyplacophore', 118 | 117: 'chambered nautilus, pearly nautilus, nautilus', 119 | 118: 'Dungeness crab, Cancer magister', 120 | 119: 'rock crab, Cancer irroratus', 121 | 120: 'fiddler crab', 122 | 121: 'king crab, Alaska crab, Alaskan king crab, Alaska king crab, Paralithodes camtschatica', 123 | 122: 'American lobster, Northern lobster, Maine lobster, Homarus americanus', 124 | 123: 'spiny lobster, langouste, rock lobster, crawfish, crayfish, sea crawfish', 125 | 124: 'crayfish, crawfish, crawdad, crawdaddy', 126 | 125: 'hermit crab', 127 | 126: 'isopod', 128 | 127: 'white stork, Ciconia ciconia', 129 | 128: 'black stork, Ciconia nigra', 130 | 129: 'spoonbill', 131 | 130: 'flamingo', 132 | 131: 'little blue heron, Egretta caerulea', 133 | 132: 'American egret, great white heron, Egretta albus', 134 | 133: 'bittern', 135 | 134: 'crane', 136 | 135: 'limpkin, Aramus pictus', 137 | 136: 'European gallinule, Porphyrio porphyrio', 138 | 137: 'American coot, marsh hen, mud hen, water hen, Fulica americana', 139 | 138: 'bustard', 140 | 139: 'ruddy turnstone, Arenaria interpres', 141 | 140: 'red-backed sandpiper, dunlin, Erolia alpina', 142 | 141: 'redshank, Tringa totanus', 143 | 142: 'dowitcher', 144 | 143: 'oystercatcher, oyster catcher', 145 | 144: 'pelican', 146 | 145: 'king penguin, Aptenodytes patagonica', 147 | 146: 'albatross, mollymawk', 148 | 147: 'grey whale, gray whale, devilfish, Eschrichtius gibbosus, Eschrichtius robustus', 149 | 148: 'killer whale, killer, orca, grampus, sea wolf, Orcinus orca', 150 | 149: 'dugong, Dugong dugon', 151 | 150: 'sea lion', 152 | 151: 'Chihuahua', 153 | 152: 'Japanese spaniel', 154 | 153: 'Maltese dog, Maltese terrier, Maltese', 155 | 154: 'Pekinese, Pekingese, Peke', 156 | 155: 'Shih-Tzu', 157 | 156: 'Blenheim spaniel', 158 | 157: 'papillon', 159 | 158: 'toy terrier', 160 | 159: 'Rhodesian ridgeback', 161 | 160: 'Afghan hound, Afghan', 162 | 161: 'basset, basset hound', 163 | 162: 'beagle', 164 | 163: 'bloodhound, sleuthhound', 165 | 164: 'bluetick', 166 | 165: 'black-and-tan coonhound', 167 | 166: 'Walker hound, Walker foxhound', 168 | 167: 'English foxhound', 169 | 168: 'redbone', 170 | 169: 'borzoi, Russian wolfhound', 171 | 170: 'Irish wolfhound', 172 | 171: 'Italian greyhound', 173 | 172: 'whippet', 174 | 173: 'Ibizan hound, Ibizan Podenco', 175 | 174: 'Norwegian elkhound, elkhound', 176 | 175: 'otterhound, otter hound', 177 | 176: 'Saluki, gazelle hound', 178 | 177: 'Scottish deerhound, deerhound', 179 | 178: 'Weimaraner', 180 | 179: 'Staffordshire bullterrier, Staffordshire bull terrier', 181 | 180: 'American Staffordshire terrier, Staffordshire terrier, American pit bull terrier, pit bull terrier', 182 | 181: 'Bedlington terrier', 183 | 182: 'Border terrier', 184 | 183: 'Kerry blue terrier', 185 | 184: 'Irish terrier', 186 | 185: 'Norfolk terrier', 187 | 186: 'Norwich terrier', 188 | 187: 'Yorkshire terrier', 189 | 188: 'wire-haired fox terrier', 190 | 189: 'Lakeland terrier', 191 | 190: 'Sealyham terrier, Sealyham', 192 | 191: 'Airedale, Airedale terrier', 193 | 192: 'cairn, cairn terrier', 194 | 193: 'Australian terrier', 195 | 194: 'Dandie Dinmont, Dandie Dinmont terrier', 196 | 195: 'Boston bull, Boston terrier', 197 | 196: 'miniature schnauzer', 198 | 197: 'giant schnauzer', 199 | 198: 'standard schnauzer', 200 | 199: 'Scotch terrier, Scottish terrier, Scottie', 201 | 200: 'Tibetan terrier, chrysanthemum dog', 202 | 201: 'silky terrier, Sydney silky', 203 | 202: 'soft-coated wheaten terrier', 204 | 203: 'West Highland white terrier', 205 | 204: 'Lhasa, Lhasa apso', 206 | 205: 'flat-coated retriever', 207 | 206: 'curly-coated retriever', 208 | 207: 'golden retriever', 209 | 208: 'Labrador retriever', 210 | 209: 'Chesapeake Bay retriever', 211 | 210: 'German short-haired pointer', 212 | 211: 'vizsla, Hungarian pointer', 213 | 212: 'English setter', 214 | 213: 'Irish setter, red setter', 215 | 214: 'Gordon setter', 216 | 215: 'Brittany spaniel', 217 | 216: 'clumber, clumber spaniel', 218 | 217: 'English springer, English springer spaniel', 219 | 218: 'Welsh springer spaniel', 220 | 219: 'cocker spaniel, English cocker spaniel, cocker', 221 | 220: 'Sussex spaniel', 222 | 221: 'Irish water spaniel', 223 | 222: 'kuvasz', 224 | 223: 'schipperke', 225 | 224: 'groenendael', 226 | 225: 'malinois', 227 | 226: 'briard', 228 | 227: 'kelpie', 229 | 228: 'komondor', 230 | 229: 'Old English sheepdog, bobtail', 231 | 230: 'Shetland sheepdog, Shetland sheep dog, Shetland', 232 | 231: 'collie', 233 | 232: 'Border collie', 234 | 233: 'Bouvier des Flandres, Bouviers des Flandres', 235 | 234: 'Rottweiler', 236 | 235: 'German shepherd, German shepherd dog, German police dog, alsatian', 237 | 236: 'Doberman, Doberman pinscher', 238 | 237: 'miniature pinscher', 239 | 238: 'Greater Swiss Mountain dog', 240 | 239: 'Bernese mountain dog', 241 | 240: 'Appenzeller', 242 | 241: 'EntleBucher', 243 | 242: 'boxer', 244 | 243: 'bull mastiff', 245 | 244: 'Tibetan mastiff', 246 | 245: 'French bulldog', 247 | 246: 'Great Dane', 248 | 247: 'Saint Bernard, St Bernard', 249 | 248: 'Eskimo dog, husky', 250 | 249: 'malamute, malemute, Alaskan malamute', 251 | 250: 'Siberian husky', 252 | 251: 'dalmatian, coach dog, carriage dog', 253 | 252: 'affenpinscher, monkey pinscher, monkey dog', 254 | 253: 'basenji', 255 | 254: 'pug, pug-dog', 256 | 255: 'Leonberg', 257 | 256: 'Newfoundland, Newfoundland dog', 258 | 257: 'Great Pyrenees', 259 | 258: 'Samoyed, Samoyede', 260 | 259: 'Pomeranian', 261 | 260: 'chow, chow chow', 262 | 261: 'keeshond', 263 | 262: 'Brabancon griffon', 264 | 263: 'Pembroke, Pembroke Welsh corgi', 265 | 264: 'Cardigan, Cardigan Welsh corgi', 266 | 265: 'toy poodle', 267 | 266: 'miniature poodle', 268 | 267: 'standard poodle', 269 | 268: 'Mexican hairless', 270 | 269: 'timber wolf, grey wolf, gray wolf, Canis lupus', 271 | 270: 'white wolf, Arctic wolf, Canis lupus tundrarum', 272 | 271: 'red wolf, maned wolf, Canis rufus, Canis niger', 273 | 272: 'coyote, prairie wolf, brush wolf, Canis latrans', 274 | 273: 'dingo, warrigal, warragal, Canis dingo', 275 | 274: 'dhole, Cuon alpinus', 276 | 275: 'African hunting dog, hyena dog, Cape hunting dog, Lycaon pictus', 277 | 276: 'hyena, hyaena', 278 | 277: 'red fox, Vulpes vulpes', 279 | 278: 'kit fox, Vulpes macrotis', 280 | 279: 'Arctic fox, white fox, Alopex lagopus', 281 | 280: 'grey fox, gray fox, Urocyon cinereoargenteus', 282 | 281: 'tabby, tabby cat', 283 | 282: 'tiger cat', 284 | 283: 'Persian cat', 285 | 284: 'Siamese cat, Siamese', 286 | 285: 'Egyptian cat', 287 | 286: 'cougar, puma, catamount, mountain lion, painter, panther, Felis concolor', 288 | 287: 'lynx, catamount', 289 | 288: 'leopard, Panthera pardus', 290 | 289: 'snow leopard, ounce, Panthera uncia', 291 | 290: 'jaguar, panther, Panthera onca, Felis onca', 292 | 291: 'lion, king of beasts, Panthera leo', 293 | 292: 'tiger, Panthera tigris', 294 | 293: 'cheetah, chetah, Acinonyx jubatus', 295 | 294: 'brown bear, bruin, Ursus arctos', 296 | 295: 'American black bear, black bear, Ursus americanus, Euarctos americanus', 297 | 296: 'ice bear, polar bear, Ursus Maritimus, Thalarctos maritimus', 298 | 297: 'sloth bear, Melursus ursinus, Ursus ursinus', 299 | 298: 'mongoose', 300 | 299: 'meerkat, mierkat', 301 | 300: 'tiger beetle', 302 | 301: 'ladybug, ladybeetle, lady beetle, ladybird, ladybird beetle', 303 | 302: 'ground beetle, carabid beetle', 304 | 303: 'long-horned beetle, longicorn, longicorn beetle', 305 | 304: 'leaf beetle, chrysomelid', 306 | 305: 'dung beetle', 307 | 306: 'rhinoceros beetle', 308 | 307: 'weevil', 309 | 308: 'fly', 310 | 309: 'bee', 311 | 310: 'ant, emmet, pismire', 312 | 311: 'grasshopper, hopper', 313 | 312: 'cricket', 314 | 313: 'walking stick, walkingstick, stick insect', 315 | 314: 'cockroach, roach', 316 | 315: 'mantis, mantid', 317 | 316: 'cicada, cicala', 318 | 317: 'leafhopper', 319 | 318: 'lacewing, lacewing fly', 320 | 319: "dragonfly, darning needle, devil's darning needle, sewing needle, snake feeder, snake doctor, mosquito hawk, skeeter hawk", 321 | 320: 'damselfly', 322 | 321: 'admiral', 323 | 322: 'ringlet, ringlet butterfly', 324 | 323: 'monarch, monarch butterfly, milkweed butterfly, Danaus plexippus', 325 | 324: 'cabbage butterfly', 326 | 325: 'sulphur butterfly, sulfur butterfly', 327 | 326: 'lycaenid, lycaenid butterfly', 328 | 327: 'starfish, sea star', 329 | 328: 'sea urchin', 330 | 329: 'sea cucumber, holothurian', 331 | 330: 'wood rabbit, cottontail, cottontail rabbit', 332 | 331: 'hare', 333 | 332: 'Angora, Angora rabbit', 334 | 333: 'hamster', 335 | 334: 'porcupine, hedgehog', 336 | 335: 'fox squirrel, eastern fox squirrel, Sciurus niger', 337 | 336: 'marmot', 338 | 337: 'beaver', 339 | 338: 'guinea pig, Cavia cobaya', 340 | 339: 'sorrel', 341 | 340: 'zebra', 342 | 341: 'hog, pig, grunter, squealer, Sus scrofa', 343 | 342: 'wild boar, boar, Sus scrofa', 344 | 343: 'warthog', 345 | 344: 'hippopotamus, hippo, river horse, Hippopotamus amphibius', 346 | 345: 'ox', 347 | 346: 'water buffalo, water ox, Asiatic buffalo, Bubalus bubalis', 348 | 347: 'bison', 349 | 348: 'ram, tup', 350 | 349: 'bighorn, bighorn sheep, cimarron, Rocky Mountain bighorn, Rocky Mountain sheep, Ovis canadensis', 351 | 350: 'ibex, Capra ibex', 352 | 351: 'hartebeest', 353 | 352: 'impala, Aepyceros melampus', 354 | 353: 'gazelle', 355 | 354: 'Arabian camel, dromedary, Camelus dromedarius', 356 | 355: 'llama', 357 | 356: 'weasel', 358 | 357: 'mink', 359 | 358: 'polecat, fitch, foulmart, foumart, Mustela putorius', 360 | 359: 'black-footed ferret, ferret, Mustela nigripes', 361 | 360: 'otter', 362 | 361: 'skunk, polecat, wood pussy', 363 | 362: 'badger', 364 | 363: 'armadillo', 365 | 364: 'three-toed sloth, ai, Bradypus tridactylus', 366 | 365: 'orangutan, orang, orangutang, Pongo pygmaeus', 367 | 366: 'gorilla, Gorilla gorilla', 368 | 367: 'chimpanzee, chimp, Pan troglodytes', 369 | 368: 'gibbon, Hylobates lar', 370 | 369: 'siamang, Hylobates syndactylus, Symphalangus syndactylus', 371 | 370: 'guenon, guenon monkey', 372 | 371: 'patas, hussar monkey, Erythrocebus patas', 373 | 372: 'baboon', 374 | 373: 'macaque', 375 | 374: 'langur', 376 | 375: 'colobus, colobus monkey', 377 | 376: 'proboscis monkey, Nasalis larvatus', 378 | 377: 'marmoset', 379 | 378: 'capuchin, ringtail, Cebus capucinus', 380 | 379: 'howler monkey, howler', 381 | 380: 'titi, titi monkey', 382 | 381: 'spider monkey, Ateles geoffroyi', 383 | 382: 'squirrel monkey, Saimiri sciureus', 384 | 383: 'Madagascar cat, ring-tailed lemur, Lemur catta', 385 | 384: 'indri, indris, Indri indri, Indri brevicaudatus', 386 | 385: 'Indian elephant, Elephas maximus', 387 | 386: 'African elephant, Loxodonta africana', 388 | 387: 'lesser panda, red panda, panda, bear cat, cat bear, Ailurus fulgens', 389 | 388: 'giant panda, panda, panda bear, coon bear, Ailuropoda melanoleuca', 390 | 389: 'barracouta, snoek', 391 | 390: 'eel', 392 | 391: 'coho, cohoe, coho salmon, blue jack, silver salmon, Oncorhynchus kisutch', 393 | 392: 'rock beauty, Holocanthus tricolor', 394 | 393: 'anemone fish', 395 | 394: 'sturgeon', 396 | 395: 'gar, garfish, garpike, billfish, Lepisosteus osseus', 397 | 396: 'lionfish', 398 | 397: 'puffer, pufferfish, blowfish, globefish', 399 | 398: 'abacus', 400 | 399: 'abaya', 401 | 400: "academic gown, academic robe, judge's robe", 402 | 401: 'accordion, piano accordion, squeeze box', 403 | 402: 'acoustic guitar', 404 | 403: 'aircraft carrier, carrier, flattop, attack aircraft carrier', 405 | 404: 'airliner', 406 | 405: 'airship, dirigible', 407 | 406: 'altar', 408 | 407: 'ambulance', 409 | 408: 'amphibian, amphibious vehicle', 410 | 409: 'analog clock', 411 | 410: 'apiary, bee house', 412 | 411: 'apron', 413 | 412: 'ashcan, trash can, garbage can, wastebin, ash bin, ash-bin, ashbin, dustbin, trash barrel, trash bin', 414 | 413: 'assault rifle, assault gun', 415 | 414: 'backpack, back pack, knapsack, packsack, rucksack, haversack', 416 | 415: 'bakery, bakeshop, bakehouse', 417 | 416: 'balance beam, beam', 418 | 417: 'balloon', 419 | 418: 'ballpoint, ballpoint pen, ballpen, Biro', 420 | 419: 'Band Aid', 421 | 420: 'banjo', 422 | 421: 'bannister, banister, balustrade, balusters, handrail', 423 | 422: 'barbell', 424 | 423: 'barber chair', 425 | 424: 'barbershop', 426 | 425: 'barn', 427 | 426: 'barometer', 428 | 427: 'barrel, cask', 429 | 428: 'barrow, garden cart, lawn cart, wheelbarrow', 430 | 429: 'baseball', 431 | 430: 'basketball', 432 | 431: 'bassinet', 433 | 432: 'bassoon', 434 | 433: 'bathing cap, swimming cap', 435 | 434: 'bath towel', 436 | 435: 'bathtub, bathing tub, bath, tub', 437 | 436: 'beach wagon, station wagon, wagon, estate car, beach waggon, station waggon, waggon', 438 | 437: 'beacon, lighthouse, beacon light, pharos', 439 | 438: 'beaker', 440 | 439: 'bearskin, busby, shako', 441 | 440: 'beer bottle', 442 | 441: 'beer glass', 443 | 442: 'bell cote, bell cot', 444 | 443: 'bib', 445 | 444: 'bicycle-built-for-two, tandem bicycle, tandem', 446 | 445: 'bikini, two-piece', 447 | 446: 'binder, ring-binder', 448 | 447: 'binoculars, field glasses, opera glasses', 449 | 448: 'birdhouse', 450 | 449: 'boathouse', 451 | 450: 'bobsled, bobsleigh, bob', 452 | 451: 'bolo tie, bolo, bola tie, bola', 453 | 452: 'bonnet, poke bonnet', 454 | 453: 'bookcase', 455 | 454: 'bookshop, bookstore, bookstall', 456 | 455: 'bottlecap', 457 | 456: 'bow', 458 | 457: 'bow tie, bow-tie, bowtie', 459 | 458: 'brass, memorial tablet, plaque', 460 | 459: 'brassiere, bra, bandeau', 461 | 460: 'breakwater, groin, groyne, mole, bulwark, seawall, jetty', 462 | 461: 'breastplate, aegis, egis', 463 | 462: 'broom', 464 | 463: 'bucket, pail', 465 | 464: 'buckle', 466 | 465: 'bulletproof vest', 467 | 466: 'bullet train, bullet', 468 | 467: 'butcher shop, meat market', 469 | 468: 'cab, hack, taxi, taxicab', 470 | 469: 'caldron, cauldron', 471 | 470: 'candle, taper, wax light', 472 | 471: 'cannon', 473 | 472: 'canoe', 474 | 473: 'can opener, tin opener', 475 | 474: 'cardigan', 476 | 475: 'car mirror', 477 | 476: 'carousel, carrousel, merry-go-round, roundabout, whirligig', 478 | 477: "carpenter's kit, tool kit", 479 | 478: 'carton', 480 | 479: 'car wheel', 481 | 480: 'cash machine, cash dispenser, automated teller machine, automatic teller machine, automated teller, automatic teller, ATM', 482 | 481: 'cassette', 483 | 482: 'cassette player', 484 | 483: 'castle', 485 | 484: 'catamaran', 486 | 485: 'CD player', 487 | 486: 'cello, violoncello', 488 | 487: 'cellular telephone, cellular phone, cellphone, cell, mobile phone', 489 | 488: 'chain', 490 | 489: 'chainlink fence', 491 | 490: 'chain mail, ring mail, mail, chain armor, chain armour, ring armor, ring armour', 492 | 491: 'chain saw, chainsaw', 493 | 492: 'chest', 494 | 493: 'chiffonier, commode', 495 | 494: 'chime, bell, gong', 496 | 495: 'china cabinet, china closet', 497 | 496: 'Christmas stocking', 498 | 497: 'church, church building', 499 | 498: 'cinema, movie theater, movie theatre, movie house, picture palace', 500 | 499: 'cleaver, meat cleaver, chopper', 501 | 500: 'cliff dwelling', 502 | 501: 'cloak', 503 | 502: 'clog, geta, patten, sabot', 504 | 503: 'cocktail shaker', 505 | 504: 'coffee mug', 506 | 505: 'coffeepot', 507 | 506: 'coil, spiral, volute, whorl, helix', 508 | 507: 'combination lock', 509 | 508: 'computer keyboard, keypad', 510 | 509: 'confectionery, confectionary, candy store', 511 | 510: 'container ship, containership, container vessel', 512 | 511: 'convertible', 513 | 512: 'corkscrew, bottle screw', 514 | 513: 'cornet, horn, trumpet, trump', 515 | 514: 'cowboy boot', 516 | 515: 'cowboy hat, ten-gallon hat', 517 | 516: 'cradle', 518 | 517: 'crane', 519 | 518: 'crash helmet', 520 | 519: 'crate', 521 | 520: 'crib, cot', 522 | 521: 'Crock Pot', 523 | 522: 'croquet ball', 524 | 523: 'crutch', 525 | 524: 'cuirass', 526 | 525: 'dam, dike, dyke', 527 | 526: 'desk', 528 | 527: 'desktop computer', 529 | 528: 'dial telephone, dial phone', 530 | 529: 'diaper, nappy, napkin', 531 | 530: 'digital clock', 532 | 531: 'digital watch', 533 | 532: 'dining table, board', 534 | 533: 'dishrag, dishcloth', 535 | 534: 'dishwasher, dish washer, dishwashing machine', 536 | 535: 'disk brake, disc brake', 537 | 536: 'dock, dockage, docking facility', 538 | 537: 'dogsled, dog sled, dog sleigh', 539 | 538: 'dome', 540 | 539: 'doormat, welcome mat', 541 | 540: 'drilling platform, offshore rig', 542 | 541: 'drum, membranophone, tympan', 543 | 542: 'drumstick', 544 | 543: 'dumbbell', 545 | 544: 'Dutch oven', 546 | 545: 'electric fan, blower', 547 | 546: 'electric guitar', 548 | 547: 'electric locomotive', 549 | 548: 'entertainment center', 550 | 549: 'envelope', 551 | 550: 'espresso maker', 552 | 551: 'face powder', 553 | 552: 'feather boa, boa', 554 | 553: 'file, file cabinet, filing cabinet', 555 | 554: 'fireboat', 556 | 555: 'fire engine, fire truck', 557 | 556: 'fire screen, fireguard', 558 | 557: 'flagpole, flagstaff', 559 | 558: 'flute, transverse flute', 560 | 559: 'folding chair', 561 | 560: 'football helmet', 562 | 561: 'forklift', 563 | 562: 'fountain', 564 | 563: 'fountain pen', 565 | 564: 'four-poster', 566 | 565: 'freight car', 567 | 566: 'French horn, horn', 568 | 567: 'frying pan, frypan, skillet', 569 | 568: 'fur coat', 570 | 569: 'garbage truck, dustcart', 571 | 570: 'gasmask, respirator, gas helmet', 572 | 571: 'gas pump, gasoline pump, petrol pump, island dispenser', 573 | 572: 'goblet', 574 | 573: 'go-kart', 575 | 574: 'golf ball', 576 | 575: 'golfcart, golf cart', 577 | 576: 'gondola', 578 | 577: 'gong, tam-tam', 579 | 578: 'gown', 580 | 579: 'grand piano, grand', 581 | 580: 'greenhouse, nursery, glasshouse', 582 | 581: 'grille, radiator grille', 583 | 582: 'grocery store, grocery, food market, market', 584 | 583: 'guillotine', 585 | 584: 'hair slide', 586 | 585: 'hair spray', 587 | 586: 'half track', 588 | 587: 'hammer', 589 | 588: 'hamper', 590 | 589: 'hand blower, blow dryer, blow drier, hair dryer, hair drier', 591 | 590: 'hand-held computer, hand-held microcomputer', 592 | 591: 'handkerchief, hankie, hanky, hankey', 593 | 592: 'hard disc, hard disk, fixed disk', 594 | 593: 'harmonica, mouth organ, harp, mouth harp', 595 | 594: 'harp', 596 | 595: 'harvester, reaper', 597 | 596: 'hatchet', 598 | 597: 'holster', 599 | 598: 'home theater, home theatre', 600 | 599: 'honeycomb', 601 | 600: 'hook, claw', 602 | 601: 'hoopskirt, crinoline', 603 | 602: 'horizontal bar, high bar', 604 | 603: 'horse cart, horse-cart', 605 | 604: 'hourglass', 606 | 605: 'iPod', 607 | 606: 'iron, smoothing iron', 608 | 607: "jack-o'-lantern", 609 | 608: 'jean, blue jean, denim', 610 | 609: 'jeep, landrover', 611 | 610: 'jersey, T-shirt, tee shirt', 612 | 611: 'jigsaw puzzle', 613 | 612: 'jinrikisha, ricksha, rickshaw', 614 | 613: 'joystick', 615 | 614: 'kimono', 616 | 615: 'knee pad', 617 | 616: 'knot', 618 | 617: 'lab coat, laboratory coat', 619 | 618: 'ladle', 620 | 619: 'lampshade, lamp shade', 621 | 620: 'laptop, laptop computer', 622 | 621: 'lawn mower, mower', 623 | 622: 'lens cap, lens cover', 624 | 623: 'letter opener, paper knife, paperknife', 625 | 624: 'library', 626 | 625: 'lifeboat', 627 | 626: 'lighter, light, igniter, ignitor', 628 | 627: 'limousine, limo', 629 | 628: 'liner, ocean liner', 630 | 629: 'lipstick, lip rouge', 631 | 630: 'Loafer', 632 | 631: 'lotion', 633 | 632: 'loudspeaker, speaker, speaker unit, loudspeaker system, speaker system', 634 | 633: "loupe, jeweler's loupe", 635 | 634: 'lumbermill, sawmill', 636 | 635: 'magnetic compass', 637 | 636: 'mailbag, postbag', 638 | 637: 'mailbox, letter box', 639 | 638: 'maillot', 640 | 639: 'maillot, tank suit', 641 | 640: 'manhole cover', 642 | 641: 'maraca', 643 | 642: 'marimba, xylophone', 644 | 643: 'mask', 645 | 644: 'matchstick', 646 | 645: 'maypole', 647 | 646: 'maze, labyrinth', 648 | 647: 'measuring cup', 649 | 648: 'medicine chest, medicine cabinet', 650 | 649: 'megalith, megalithic structure', 651 | 650: 'microphone, mike', 652 | 651: 'microwave, microwave oven', 653 | 652: 'military uniform', 654 | 653: 'milk can', 655 | 654: 'minibus', 656 | 655: 'miniskirt, mini', 657 | 656: 'minivan', 658 | 657: 'missile', 659 | 658: 'mitten', 660 | 659: 'mixing bowl', 661 | 660: 'mobile home, manufactured home', 662 | 661: 'Model T', 663 | 662: 'modem', 664 | 663: 'monastery', 665 | 664: 'monitor', 666 | 665: 'moped', 667 | 666: 'mortar', 668 | 667: 'mortarboard', 669 | 668: 'mosque', 670 | 669: 'mosquito net', 671 | 670: 'motor scooter, scooter', 672 | 671: 'mountain bike, all-terrain bike, off-roader', 673 | 672: 'mountain tent', 674 | 673: 'mouse, computer mouse', 675 | 674: 'mousetrap', 676 | 675: 'moving van', 677 | 676: 'muzzle', 678 | 677: 'nail', 679 | 678: 'neck brace', 680 | 679: 'necklace', 681 | 680: 'nipple', 682 | 681: 'notebook, notebook computer', 683 | 682: 'obelisk', 684 | 683: 'oboe, hautboy, hautbois', 685 | 684: 'ocarina, sweet potato', 686 | 685: 'odometer, hodometer, mileometer, milometer', 687 | 686: 'oil filter', 688 | 687: 'organ, pipe organ', 689 | 688: 'oscilloscope, scope, cathode-ray oscilloscope, CRO', 690 | 689: 'overskirt', 691 | 690: 'oxcart', 692 | 691: 'oxygen mask', 693 | 692: 'packet', 694 | 693: 'paddle, boat paddle', 695 | 694: 'paddlewheel, paddle wheel', 696 | 695: 'padlock', 697 | 696: 'paintbrush', 698 | 697: "pajama, pyjama, pj's, jammies", 699 | 698: 'palace', 700 | 699: 'panpipe, pandean pipe, syrinx', 701 | 700: 'paper towel', 702 | 701: 'parachute, chute', 703 | 702: 'parallel bars, bars', 704 | 703: 'park bench', 705 | 704: 'parking meter', 706 | 705: 'passenger car, coach, carriage', 707 | 706: 'patio, terrace', 708 | 707: 'pay-phone, pay-station', 709 | 708: 'pedestal, plinth, footstall', 710 | 709: 'pencil box, pencil case', 711 | 710: 'pencil sharpener', 712 | 711: 'perfume, essence', 713 | 712: 'Petri dish', 714 | 713: 'photocopier', 715 | 714: 'pick, plectrum, plectron', 716 | 715: 'pickelhaube', 717 | 716: 'picket fence, paling', 718 | 717: 'pickup, pickup truck', 719 | 718: 'pier', 720 | 719: 'piggy bank, penny bank', 721 | 720: 'pill bottle', 722 | 721: 'pillow', 723 | 722: 'ping-pong ball', 724 | 723: 'pinwheel', 725 | 724: 'pirate, pirate ship', 726 | 725: 'pitcher, ewer', 727 | 726: "plane, carpenter's plane, woodworking plane", 728 | 727: 'planetarium', 729 | 728: 'plastic bag', 730 | 729: 'plate rack', 731 | 730: 'plow, plough', 732 | 731: "plunger, plumber's helper", 733 | 732: 'Polaroid camera, Polaroid Land camera', 734 | 733: 'pole', 735 | 734: 'police van, police wagon, paddy wagon, patrol wagon, wagon, black Maria', 736 | 735: 'poncho', 737 | 736: 'pool table, billiard table, snooker table', 738 | 737: 'pop bottle, soda bottle', 739 | 738: 'pot, flowerpot', 740 | 739: "potter's wheel", 741 | 740: 'power drill', 742 | 741: 'prayer rug, prayer mat', 743 | 742: 'printer', 744 | 743: 'prison, prison house', 745 | 744: 'projectile, missile', 746 | 745: 'projector', 747 | 746: 'puck, hockey puck', 748 | 747: 'punching bag, punch bag, punching ball, punchball', 749 | 748: 'purse', 750 | 749: 'quill, quill pen', 751 | 750: 'quilt, comforter, comfort, puff', 752 | 751: 'racer, race car, racing car', 753 | 752: 'racket, racquet', 754 | 753: 'radiator', 755 | 754: 'radio, wireless', 756 | 755: 'radio telescope, radio reflector', 757 | 756: 'rain barrel', 758 | 757: 'recreational vehicle, RV, R.V.', 759 | 758: 'reel', 760 | 759: 'reflex camera', 761 | 760: 'refrigerator, icebox', 762 | 761: 'remote control, remote', 763 | 762: 'restaurant, eating house, eating place, eatery', 764 | 763: 'revolver, six-gun, six-shooter', 765 | 764: 'rifle', 766 | 765: 'rocking chair, rocker', 767 | 766: 'rotisserie', 768 | 767: 'rubber eraser, rubber, pencil eraser', 769 | 768: 'rugby ball', 770 | 769: 'rule, ruler', 771 | 770: 'running shoe', 772 | 771: 'safe', 773 | 772: 'safety pin', 774 | 773: 'saltshaker, salt shaker', 775 | 774: 'sandal', 776 | 775: 'sarong', 777 | 776: 'sax, saxophone', 778 | 777: 'scabbard', 779 | 778: 'scale, weighing machine', 780 | 779: 'school bus', 781 | 780: 'schooner', 782 | 781: 'scoreboard', 783 | 782: 'screen, CRT screen', 784 | 783: 'screw', 785 | 784: 'screwdriver', 786 | 785: 'seat belt, seatbelt', 787 | 786: 'sewing machine', 788 | 787: 'shield, buckler', 789 | 788: 'shoe shop, shoe-shop, shoe store', 790 | 789: 'shoji', 791 | 790: 'shopping basket', 792 | 791: 'shopping cart', 793 | 792: 'shovel', 794 | 793: 'shower cap', 795 | 794: 'shower curtain', 796 | 795: 'ski', 797 | 796: 'ski mask', 798 | 797: 'sleeping bag', 799 | 798: 'slide rule, slipstick', 800 | 799: 'sliding door', 801 | 800: 'slot, one-armed bandit', 802 | 801: 'snorkel', 803 | 802: 'snowmobile', 804 | 803: 'snowplow, snowplough', 805 | 804: 'soap dispenser', 806 | 805: 'soccer ball', 807 | 806: 'sock', 808 | 807: 'solar dish, solar collector, solar furnace', 809 | 808: 'sombrero', 810 | 809: 'soup bowl', 811 | 810: 'space bar', 812 | 811: 'space heater', 813 | 812: 'space shuttle', 814 | 813: 'spatula', 815 | 814: 'speedboat', 816 | 815: "spider web, spider's web", 817 | 816: 'spindle', 818 | 817: 'sports car, sport car', 819 | 818: 'spotlight, spot', 820 | 819: 'stage', 821 | 820: 'steam locomotive', 822 | 821: 'steel arch bridge', 823 | 822: 'steel drum', 824 | 823: 'stethoscope', 825 | 824: 'stole', 826 | 825: 'stone wall', 827 | 826: 'stopwatch, stop watch', 828 | 827: 'stove', 829 | 828: 'strainer', 830 | 829: 'streetcar, tram, tramcar, trolley, trolley car', 831 | 830: 'stretcher', 832 | 831: 'studio couch, day bed', 833 | 832: 'stupa, tope', 834 | 833: 'submarine, pigboat, sub, U-boat', 835 | 834: 'suit, suit of clothes', 836 | 835: 'sundial', 837 | 836: 'sunglass', 838 | 837: 'sunglasses, dark glasses, shades', 839 | 838: 'sunscreen, sunblock, sun blocker', 840 | 839: 'suspension bridge', 841 | 840: 'swab, swob, mop', 842 | 841: 'sweatshirt', 843 | 842: 'swimming trunks, bathing trunks', 844 | 843: 'swing', 845 | 844: 'switch, electric switch, electrical switch', 846 | 845: 'syringe', 847 | 846: 'table lamp', 848 | 847: 'tank, army tank, armored combat vehicle, armoured combat vehicle', 849 | 848: 'tape player', 850 | 849: 'teapot', 851 | 850: 'teddy, teddy bear', 852 | 851: 'television, television system', 853 | 852: 'tennis ball', 854 | 853: 'thatch, thatched roof', 855 | 854: 'theater curtain, theatre curtain', 856 | 855: 'thimble', 857 | 856: 'thresher, thrasher, threshing machine', 858 | 857: 'throne', 859 | 858: 'tile roof', 860 | 859: 'toaster', 861 | 860: 'tobacco shop, tobacconist shop, tobacconist', 862 | 861: 'toilet seat', 863 | 862: 'torch', 864 | 863: 'totem pole', 865 | 864: 'tow truck, tow car, wrecker', 866 | 865: 'toyshop', 867 | 866: 'tractor', 868 | 867: 'trailer truck, tractor trailer, trucking rig, rig, articulated lorry, semi', 869 | 868: 'tray', 870 | 869: 'trench coat', 871 | 870: 'tricycle, trike, velocipede', 872 | 871: 'trimaran', 873 | 872: 'tripod', 874 | 873: 'triumphal arch', 875 | 874: 'trolleybus, trolley coach, trackless trolley', 876 | 875: 'trombone', 877 | 876: 'tub, vat', 878 | 877: 'turnstile', 879 | 878: 'typewriter keyboard', 880 | 879: 'umbrella', 881 | 880: 'unicycle, monocycle', 882 | 881: 'upright, upright piano', 883 | 882: 'vacuum, vacuum cleaner', 884 | 883: 'vase', 885 | 884: 'vault', 886 | 885: 'velvet', 887 | 886: 'vending machine', 888 | 887: 'vestment', 889 | 888: 'viaduct', 890 | 889: 'violin, fiddle', 891 | 890: 'volleyball', 892 | 891: 'waffle iron', 893 | 892: 'wall clock', 894 | 893: 'wallet, billfold, notecase, pocketbook', 895 | 894: 'wardrobe, closet, press', 896 | 895: 'warplane, military plane', 897 | 896: 'washbasin, handbasin, washbowl, lavabo, wash-hand basin', 898 | 897: 'washer, automatic washer, washing machine', 899 | 898: 'water bottle', 900 | 899: 'water jug', 901 | 900: 'water tower', 902 | 901: 'whiskey jug', 903 | 902: 'whistle', 904 | 903: 'wig', 905 | 904: 'window screen', 906 | 905: 'window shade', 907 | 906: 'Windsor tie', 908 | 907: 'wine bottle', 909 | 908: 'wing', 910 | 909: 'wok', 911 | 910: 'wooden spoon', 912 | 911: 'wool, woolen, woollen', 913 | 912: 'worm fence, snake fence, snake-rail fence, Virginia fence', 914 | 913: 'wreck', 915 | 914: 'yawl', 916 | 915: 'yurt', 917 | 916: 'web site, website, internet site, site', 918 | 917: 'comic book', 919 | 918: 'crossword puzzle, crossword', 920 | 919: 'street sign', 921 | 920: 'traffic light, traffic signal, stoplight', 922 | 921: 'book jacket, dust cover, dust jacket, dust wrapper', 923 | 922: 'menu', 924 | 923: 'plate', 925 | 924: 'guacamole', 926 | 925: 'consomme', 927 | 926: 'hot pot, hotpot', 928 | 927: 'trifle', 929 | 928: 'ice cream, icecream', 930 | 929: 'ice lolly, lolly, lollipop, popsicle', 931 | 930: 'French loaf', 932 | 931: 'bagel, beigel', 933 | 932: 'pretzel', 934 | 933: 'cheeseburger', 935 | 934: 'hotdog, hot dog, red hot', 936 | 935: 'mashed potato', 937 | 936: 'head cabbage', 938 | 937: 'broccoli', 939 | 938: 'cauliflower', 940 | 939: 'zucchini, courgette', 941 | 940: 'spaghetti squash', 942 | 941: 'acorn squash', 943 | 942: 'butternut squash', 944 | 943: 'cucumber, cuke', 945 | 944: 'artichoke, globe artichoke', 946 | 945: 'bell pepper', 947 | 946: 'cardoon', 948 | 947: 'mushroom', 949 | 948: 'Granny Smith', 950 | 949: 'strawberry', 951 | 950: 'orange', 952 | 951: 'lemon', 953 | 952: 'fig', 954 | 953: 'pineapple, ananas', 955 | 954: 'banana', 956 | 955: 'jackfruit, jak, jack', 957 | 956: 'custard apple', 958 | 957: 'pomegranate', 959 | 958: 'hay', 960 | 959: 'carbonara', 961 | 960: 'chocolate sauce, chocolate syrup', 962 | 961: 'dough', 963 | 962: 'meat loaf, meatloaf', 964 | 963: 'pizza, pizza pie', 965 | 964: 'potpie', 966 | 965: 'burrito', 967 | 966: 'red wine', 968 | 967: 'espresso', 969 | 968: 'cup', 970 | 969: 'eggnog', 971 | 970: 'alp', 972 | 971: 'bubble', 973 | 972: 'cliff, drop, drop-off', 974 | 973: 'coral reef', 975 | 974: 'geyser', 976 | 975: 'lakeside, lakeshore', 977 | 976: 'promontory, headland, head, foreland', 978 | 977: 'sandbar, sand bar', 979 | 978: 'seashore, coast, seacoast, sea-coast', 980 | 979: 'valley, vale', 981 | 980: 'volcano', 982 | 981: 'ballplayer, baseball player', 983 | 982: 'groom, bridegroom', 984 | 983: 'scuba diver', 985 | 984: 'rapeseed', 986 | 985: 'daisy', 987 | 986: "yellow lady's slipper, yellow lady-slipper, Cypripedium calceolus, Cypripedium parviflorum", 988 | 987: 'corn', 989 | 988: 'acorn', 990 | 989: 'hip, rose hip, rosehip', 991 | 990: 'buckeye, horse chestnut, conker', 992 | 991: 'coral fungus', 993 | 992: 'agaric', 994 | 993: 'gyromitra', 995 | 994: 'stinkhorn, carrion fungus', 996 | 995: 'earthstar', 997 | 996: 'hen-of-the-woods, hen of the woods, Polyporus frondosus, Grifola frondosa', 998 | 997: 'bolete', 999 | 998: 'ear, spike, capitulum', 1000 | 999: 'toilet tissue, toilet paper, bathroom tissue'} -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/extract_feature/validation_utils/convert_ground_truth_labels/old_classes_raw.txt: -------------------------------------------------------------------------------- 1 | n02119789 1 kit_fox 2 | n02100735 2 English_setter 3 | n02110185 3 Siberian_husky 4 | n02096294 4 Australian_terrier 5 | n02102040 5 English_springer 6 | n02066245 6 grey_whale 7 | n02509815 7 lesser_panda 8 | n02124075 8 Egyptian_cat 9 | n02417914 9 ibex 10 | n02123394 10 Persian_cat 11 | n02125311 11 cougar 12 | n02423022 12 gazelle 13 | n02346627 13 porcupine 14 | n02077923 14 sea_lion 15 | n02110063 15 malamute 16 | n02447366 16 badger 17 | n02109047 17 Great_Dane 18 | n02089867 18 Walker_hound 19 | n02102177 19 Welsh_springer_spaniel 20 | n02091134 20 whippet 21 | n02092002 21 Scottish_deerhound 22 | n02071294 22 killer_whale 23 | n02442845 23 mink 24 | n02504458 24 African_elephant 25 | n02092339 25 Weimaraner 26 | n02098105 26 soft-coated_wheaten_terrier 27 | n02096437 27 Dandie_Dinmont 28 | n02114712 28 red_wolf 29 | n02105641 29 Old_English_sheepdog 30 | n02128925 30 jaguar 31 | n02091635 31 otterhound 32 | n02088466 32 bloodhound 33 | n02096051 33 Airedale 34 | n02117135 34 hyena 35 | n02138441 35 meerkat 36 | n02097130 36 giant_schnauzer 37 | n02493509 37 titi 38 | n02457408 38 three-toed_sloth 39 | n02389026 39 sorrel 40 | n02443484 40 black-footed_ferret 41 | n02110341 41 dalmatian 42 | n02089078 42 black-and-tan_coonhound 43 | n02086910 43 papillon 44 | n02445715 44 skunk 45 | n02093256 45 Staffordshire_bullterrier 46 | n02113978 46 Mexican_hairless 47 | n02106382 47 Bouvier_des_Flandres 48 | n02441942 48 weasel 49 | n02113712 49 miniature_poodle 50 | n02113186 50 Cardigan 51 | n02105162 51 malinois 52 | n02415577 52 bighorn 53 | n02356798 53 fox_squirrel 54 | n02488702 54 colobus 55 | n02123159 55 tiger_cat 56 | n02098413 56 Lhasa 57 | n02422699 57 impala 58 | n02114855 58 coyote 59 | n02094433 59 Yorkshire_terrier 60 | n02111277 60 Newfoundland 61 | n02132136 61 brown_bear 62 | n02119022 62 red_fox 63 | n02091467 63 Norwegian_elkhound 64 | n02106550 64 Rottweiler 65 | n02422106 65 hartebeest 66 | n02091831 66 Saluki 67 | n02120505 67 grey_fox 68 | n02104365 68 schipperke 69 | n02086079 69 Pekinese 70 | n02112706 70 Brabancon_griffon 71 | n02098286 71 West_Highland_white_terrier 72 | n02095889 72 Sealyham_terrier 73 | n02484975 73 guenon 74 | n02137549 74 mongoose 75 | n02500267 75 indri 76 | n02129604 76 tiger 77 | n02090721 77 Irish_wolfhound 78 | n02396427 78 wild_boar 79 | n02108000 79 EntleBucher 80 | n02391049 80 zebra 81 | n02412080 81 ram 82 | n02108915 82 French_bulldog 83 | n02480495 83 orangutan 84 | n02110806 84 basenji 85 | n02128385 85 leopard 86 | n02107683 86 Bernese_mountain_dog 87 | n02085936 87 Maltese_dog 88 | n02094114 88 Norfolk_terrier 89 | n02087046 89 toy_terrier 90 | n02100583 90 vizsla 91 | n02096177 91 cairn 92 | n02494079 92 squirrel_monkey 93 | n02105056 93 groenendael 94 | n02101556 94 clumber 95 | n02123597 95 Siamese_cat 96 | n02481823 96 chimpanzee 97 | n02105505 97 komondor 98 | n02088094 98 Afghan_hound 99 | n02085782 99 Japanese_spaniel 100 | n02489166 100 proboscis_monkey 101 | n02364673 101 guinea_pig 102 | n02114548 102 white_wolf 103 | n02134084 103 ice_bear 104 | n02480855 104 gorilla 105 | n02090622 105 borzoi 106 | n02113624 106 toy_poodle 107 | n02093859 107 Kerry_blue_terrier 108 | n02403003 108 ox 109 | n02097298 109 Scotch_terrier 110 | n02108551 110 Tibetan_mastiff 111 | n02493793 111 spider_monkey 112 | n02107142 112 Doberman 113 | n02096585 113 Boston_bull 114 | n02107574 114 Greater_Swiss_Mountain_dog 115 | n02107908 115 Appenzeller 116 | n02086240 116 Shih-Tzu 117 | n02102973 117 Irish_water_spaniel 118 | n02112018 118 Pomeranian 119 | n02093647 119 Bedlington_terrier 120 | n02397096 120 warthog 121 | n02437312 121 Arabian_camel 122 | n02483708 122 siamang 123 | n02097047 123 miniature_schnauzer 124 | n02106030 124 collie 125 | n02099601 125 golden_retriever 126 | n02093991 126 Irish_terrier 127 | n02110627 127 affenpinscher 128 | n02106166 128 Border_collie 129 | n02326432 129 hare 130 | n02108089 130 boxer 131 | n02097658 131 silky_terrier 132 | n02088364 132 beagle 133 | n02111129 133 Leonberg 134 | n02100236 134 German_short-haired_pointer 135 | n02486261 135 patas 136 | n02115913 136 dhole 137 | n02486410 137 baboon 138 | n02487347 138 macaque 139 | n02099849 139 Chesapeake_Bay_retriever 140 | n02108422 140 bull_mastiff 141 | n02104029 141 kuvasz 142 | n02492035 142 capuchin 143 | n02110958 143 pug 144 | n02099429 144 curly-coated_retriever 145 | n02094258 145 Norwich_terrier 146 | n02099267 146 flat-coated_retriever 147 | n02395406 147 hog 148 | n02112350 148 keeshond 149 | n02109961 149 Eskimo_dog 150 | n02101388 150 Brittany_spaniel 151 | n02113799 151 standard_poodle 152 | n02095570 152 Lakeland_terrier 153 | n02128757 153 snow_leopard 154 | n02101006 154 Gordon_setter 155 | n02115641 155 dingo 156 | n02097209 156 standard_schnauzer 157 | n02342885 157 hamster 158 | n02097474 158 Tibetan_terrier 159 | n02120079 159 Arctic_fox 160 | n02095314 160 wire-haired_fox_terrier 161 | n02088238 161 basset 162 | n02408429 162 water_buffalo 163 | n02133161 163 American_black_bear 164 | n02328150 164 Angora 165 | n02410509 165 bison 166 | n02492660 166 howler_monkey 167 | n02398521 167 hippopotamus 168 | n02112137 168 chow 169 | n02510455 169 giant_panda 170 | n02093428 170 American_Staffordshire_terrier 171 | n02105855 171 Shetland_sheepdog 172 | n02111500 172 Great_Pyrenees 173 | n02085620 173 Chihuahua 174 | n02123045 174 tabby 175 | n02490219 175 marmoset 176 | n02099712 176 Labrador_retriever 177 | n02109525 177 Saint_Bernard 178 | n02454379 178 armadillo 179 | n02111889 179 Samoyed 180 | n02088632 180 bluetick 181 | n02090379 181 redbone 182 | n02443114 182 polecat 183 | n02361337 183 marmot 184 | n02105412 184 kelpie 185 | n02483362 185 gibbon 186 | n02437616 186 llama 187 | n02107312 187 miniature_pinscher 188 | n02325366 188 wood_rabbit 189 | n02091032 189 Italian_greyhound 190 | n02129165 190 lion 191 | n02102318 191 cocker_spaniel 192 | n02100877 192 Irish_setter 193 | n02074367 193 dugong 194 | n02504013 194 Indian_elephant 195 | n02363005 195 beaver 196 | n02102480 196 Sussex_spaniel 197 | n02113023 197 Pembroke 198 | n02086646 198 Blenheim_spaniel 199 | n02497673 199 Madagascar_cat 200 | n02087394 200 Rhodesian_ridgeback 201 | n02127052 201 lynx 202 | n02116738 202 African_hunting_dog 203 | n02488291 203 langur 204 | n02091244 204 Ibizan_hound 205 | n02114367 205 timber_wolf 206 | n02130308 206 cheetah 207 | n02089973 207 English_foxhound 208 | n02105251 208 briard 209 | n02134418 209 sloth_bear 210 | n02093754 210 Border_terrier 211 | n02106662 211 German_shepherd 212 | n02444819 212 otter 213 | n01882714 213 koala 214 | n01871265 214 tusker 215 | n01872401 215 echidna 216 | n01877812 216 wallaby 217 | n01873310 217 platypus 218 | n01883070 218 wombat 219 | n04086273 219 revolver 220 | n04507155 220 umbrella 221 | n04147183 221 schooner 222 | n04254680 222 soccer_ball 223 | n02672831 223 accordion 224 | n02219486 224 ant 225 | n02317335 225 starfish 226 | n01968897 226 chambered_nautilus 227 | n03452741 227 grand_piano 228 | n03642806 228 laptop 229 | n07745940 229 strawberry 230 | n02690373 230 airliner 231 | n04552348 231 warplane 232 | n02692877 232 airship 233 | n02782093 233 balloon 234 | n04266014 234 space_shuttle 235 | n03344393 235 fireboat 236 | n03447447 236 gondola 237 | n04273569 237 speedboat 238 | n03662601 238 lifeboat 239 | n02951358 239 canoe 240 | n04612504 240 yawl 241 | n02981792 241 catamaran 242 | n04483307 242 trimaran 243 | n03095699 243 container_ship 244 | n03673027 244 liner 245 | n03947888 245 pirate 246 | n02687172 246 aircraft_carrier 247 | n04347754 247 submarine 248 | n04606251 248 wreck 249 | n03478589 249 half_track 250 | n04389033 250 tank 251 | n03773504 251 missile 252 | n02860847 252 bobsled 253 | n03218198 253 dogsled 254 | n02835271 254 bicycle-built-for-two 255 | n03792782 255 mountain_bike 256 | n03393912 256 freight_car 257 | n03895866 257 passenger_car 258 | n02797295 258 barrow 259 | n04204347 259 shopping_cart 260 | n03791053 260 motor_scooter 261 | n03384352 261 forklift 262 | n03272562 262 electric_locomotive 263 | n04310018 263 steam_locomotive 264 | n02704792 264 amphibian 265 | n02701002 265 ambulance 266 | n02814533 266 beach_wagon 267 | n02930766 267 cab 268 | n03100240 268 convertible 269 | n03594945 269 jeep 270 | n03670208 270 limousine 271 | n03770679 271 minivan 272 | n03777568 272 Model_T 273 | n04037443 273 racer 274 | n04285008 274 sports_car 275 | n03444034 275 go-kart 276 | n03445924 276 golfcart 277 | n03785016 277 moped 278 | n04252225 278 snowplow 279 | n03345487 279 fire_engine 280 | n03417042 280 garbage_truck 281 | n03930630 281 pickup 282 | n04461696 282 tow_truck 283 | n04467665 283 trailer_truck 284 | n03796401 284 moving_van 285 | n03977966 285 police_van 286 | n04065272 286 recreational_vehicle 287 | n04335435 287 streetcar 288 | n04252077 288 snowmobile 289 | n04465501 289 tractor 290 | n03776460 290 mobile_home 291 | n04482393 291 tricycle 292 | n04509417 292 unicycle 293 | n03538406 293 horse_cart 294 | n03599486 294 jinrikisha 295 | n03868242 295 oxcart 296 | n02804414 296 bassinet 297 | n03125729 297 cradle 298 | n03131574 298 crib 299 | n03388549 299 four-poster 300 | n02870880 300 bookcase 301 | n03018349 301 china_cabinet 302 | n03742115 302 medicine_chest 303 | n03016953 303 chiffonier 304 | n04380533 304 table_lamp 305 | n03337140 305 file 306 | n03891251 306 park_bench 307 | n02791124 307 barber_chair 308 | n04429376 308 throne 309 | n03376595 309 folding_chair 310 | n04099969 310 rocking_chair 311 | n04344873 311 studio_couch 312 | n04447861 312 toilet_seat 313 | n03179701 313 desk 314 | n03982430 314 pool_table 315 | n03201208 315 dining_table 316 | n03290653 316 entertainment_center 317 | n04550184 317 wardrobe 318 | n07742313 318 Granny_Smith 319 | n07747607 319 orange 320 | n07749582 320 lemon 321 | n07753113 321 fig 322 | n07753275 322 pineapple 323 | n07753592 323 banana 324 | n07754684 324 jackfruit 325 | n07760859 325 custard_apple 326 | n07768694 326 pomegranate 327 | n12267677 327 acorn 328 | n12620546 328 hip 329 | n13133613 329 ear 330 | n11879895 330 rapeseed 331 | n12144580 331 corn 332 | n12768682 332 buckeye 333 | n03854065 333 organ 334 | n04515003 334 upright 335 | n03017168 335 chime 336 | n03249569 336 drum 337 | n03447721 337 gong 338 | n03720891 338 maraca 339 | n03721384 339 marimba 340 | n04311174 340 steel_drum 341 | n02787622 341 banjo 342 | n02992211 342 cello 343 | n04536866 343 violin 344 | n03495258 344 harp 345 | n02676566 345 acoustic_guitar 346 | n03272010 346 electric_guitar 347 | n03110669 347 cornet 348 | n03394916 348 French_horn 349 | n04487394 349 trombone 350 | n03494278 350 harmonica 351 | n03840681 351 ocarina 352 | n03884397 352 panpipe 353 | n02804610 353 bassoon 354 | n03838899 354 oboe 355 | n04141076 355 sax 356 | n03372029 356 flute 357 | n11939491 357 daisy 358 | n12057211 358 yellow_lady's_slipper 359 | n09246464 359 cliff 360 | n09468604 360 valley 361 | n09193705 361 alp 362 | n09472597 362 volcano 363 | n09399592 363 promontory 364 | n09421951 364 sandbar 365 | n09256479 365 coral_reef 366 | n09332890 366 lakeside 367 | n09428293 367 seashore 368 | n09288635 368 geyser 369 | n03498962 369 hatchet 370 | n03041632 370 cleaver 371 | n03658185 371 letter_opener 372 | n03954731 372 plane 373 | n03995372 373 power_drill 374 | n03649909 374 lawn_mower 375 | n03481172 375 hammer 376 | n03109150 376 corkscrew 377 | n02951585 377 can_opener 378 | n03970156 378 plunger 379 | n04154565 379 screwdriver 380 | n04208210 380 shovel 381 | n03967562 381 plow 382 | n03000684 382 chain_saw 383 | n01514668 383 cock 384 | n01514859 384 hen 385 | n01518878 385 ostrich 386 | n01530575 386 brambling 387 | n01531178 387 goldfinch 388 | n01532829 388 house_finch 389 | n01534433 389 junco 390 | n01537544 390 indigo_bunting 391 | n01558993 391 robin 392 | n01560419 392 bulbul 393 | n01580077 393 jay 394 | n01582220 394 magpie 395 | n01592084 395 chickadee 396 | n01601694 396 water_ouzel 397 | n01608432 397 kite 398 | n01614925 398 bald_eagle 399 | n01616318 399 vulture 400 | n01622779 400 great_grey_owl 401 | n01795545 401 black_grouse 402 | n01796340 402 ptarmigan 403 | n01797886 403 ruffed_grouse 404 | n01798484 404 prairie_chicken 405 | n01806143 405 peacock 406 | n01806567 406 quail 407 | n01807496 407 partridge 408 | n01817953 408 African_grey 409 | n01818515 409 macaw 410 | n01819313 410 sulphur-crested_cockatoo 411 | n01820546 411 lorikeet 412 | n01824575 412 coucal 413 | n01828970 413 bee_eater 414 | n01829413 414 hornbill 415 | n01833805 415 hummingbird 416 | n01843065 416 jacamar 417 | n01843383 417 toucan 418 | n01847000 418 drake 419 | n01855032 419 red-breasted_merganser 420 | n01855672 420 goose 421 | n01860187 421 black_swan 422 | n02002556 422 white_stork 423 | n02002724 423 black_stork 424 | n02006656 424 spoonbill 425 | n02007558 425 flamingo 426 | n02009912 426 American_egret 427 | n02009229 427 little_blue_heron 428 | n02011460 428 bittern 429 | n02012849 429 crane 430 | n02013706 430 limpkin 431 | n02018207 431 American_coot 432 | n02018795 432 bustard 433 | n02025239 433 ruddy_turnstone 434 | n02027492 434 red-backed_sandpiper 435 | n02028035 435 redshank 436 | n02033041 436 dowitcher 437 | n02037110 437 oystercatcher 438 | n02017213 438 European_gallinule 439 | n02051845 439 pelican 440 | n02056570 440 king_penguin 441 | n02058221 441 albatross 442 | n01484850 442 great_white_shark 443 | n01491361 443 tiger_shark 444 | n01494475 444 hammerhead 445 | n01496331 445 electric_ray 446 | n01498041 446 stingray 447 | n02514041 447 barracouta 448 | n02536864 448 coho 449 | n01440764 449 tench 450 | n01443537 450 goldfish 451 | n02526121 451 eel 452 | n02606052 452 rock_beauty 453 | n02607072 453 anemone_fish 454 | n02643566 454 lionfish 455 | n02655020 455 puffer 456 | n02640242 456 sturgeon 457 | n02641379 457 gar 458 | n01664065 458 loggerhead 459 | n01665541 459 leatherback_turtle 460 | n01667114 460 mud_turtle 461 | n01667778 461 terrapin 462 | n01669191 462 box_turtle 463 | n01675722 463 banded_gecko 464 | n01677366 464 common_iguana 465 | n01682714 465 American_chameleon 466 | n01685808 466 whiptail 467 | n01687978 467 agama 468 | n01688243 468 frilled_lizard 469 | n01689811 469 alligator_lizard 470 | n01692333 470 Gila_monster 471 | n01693334 471 green_lizard 472 | n01694178 472 African_chameleon 473 | n01695060 473 Komodo_dragon 474 | n01704323 474 triceratops 475 | n01697457 475 African_crocodile 476 | n01698640 476 American_alligator 477 | n01728572 477 thunder_snake 478 | n01728920 478 ringneck_snake 479 | n01729322 479 hognose_snake 480 | n01729977 480 green_snake 481 | n01734418 481 king_snake 482 | n01735189 482 garter_snake 483 | n01737021 483 water_snake 484 | n01739381 484 vine_snake 485 | n01740131 485 night_snake 486 | n01742172 486 boa_constrictor 487 | n01744401 487 rock_python 488 | n01748264 488 Indian_cobra 489 | n01749939 489 green_mamba 490 | n01751748 490 sea_snake 491 | n01753488 491 horned_viper 492 | n01755581 492 diamondback 493 | n01756291 493 sidewinder 494 | n01629819 494 European_fire_salamander 495 | n01630670 495 common_newt 496 | n01631663 496 eft 497 | n01632458 497 spotted_salamander 498 | n01632777 498 axolotl 499 | n01641577 499 bullfrog 500 | n01644373 500 tree_frog 501 | n01644900 501 tailed_frog 502 | n04579432 502 whistle 503 | n04592741 503 wing 504 | n03876231 504 paintbrush 505 | n03483316 505 hand_blower 506 | n03868863 506 oxygen_mask 507 | n04251144 507 snorkel 508 | n03691459 508 loudspeaker 509 | n03759954 509 microphone 510 | n04152593 510 screen 511 | n03793489 511 mouse 512 | n03271574 512 electric_fan 513 | n03843555 513 oil_filter 514 | n04332243 514 strainer 515 | n04265275 515 space_heater 516 | n04330267 516 stove 517 | n03467068 517 guillotine 518 | n02794156 518 barometer 519 | n04118776 519 rule 520 | n03841143 520 odometer 521 | n04141975 521 scale 522 | n02708093 522 analog_clock 523 | n03196217 523 digital_clock 524 | n04548280 524 wall_clock 525 | n03544143 525 hourglass 526 | n04355338 526 sundial 527 | n03891332 527 parking_meter 528 | n04328186 528 stopwatch 529 | n03197337 529 digital_watch 530 | n04317175 530 stethoscope 531 | n04376876 531 syringe 532 | n03706229 532 magnetic_compass 533 | n02841315 533 binoculars 534 | n04009552 534 projector 535 | n04356056 535 sunglasses 536 | n03692522 536 loupe 537 | n04044716 537 radio_telescope 538 | n02879718 538 bow 539 | n02950826 539 cannon 540 | n02749479 540 assault_rifle 541 | n04090263 541 rifle 542 | n04008634 542 projectile 543 | n03085013 543 computer_keyboard 544 | n04505470 544 typewriter_keyboard 545 | n03126707 545 crane 546 | n03666591 546 lighter 547 | n02666196 547 abacus 548 | n02977058 548 cash_machine 549 | n04238763 549 slide_rule 550 | n03180011 550 desktop_computer 551 | n03485407 551 hand-held_computer 552 | n03832673 552 notebook 553 | n06359193 553 web_site 554 | n03496892 554 harvester 555 | n04428191 555 thresher 556 | n04004767 556 printer 557 | n04243546 557 slot 558 | n04525305 558 vending_machine 559 | n04179913 559 sewing_machine 560 | n03602883 560 joystick 561 | n04372370 561 switch 562 | n03532672 562 hook 563 | n02974003 563 car_wheel 564 | n03874293 564 paddlewheel 565 | n03944341 565 pinwheel 566 | n03992509 566 potter's_wheel 567 | n03425413 567 gas_pump 568 | n02966193 568 carousel 569 | n04371774 569 swing 570 | n04067472 570 reel 571 | n04040759 571 radiator 572 | n04019541 572 puck 573 | n03492542 573 hard_disc 574 | n04355933 574 sunglass 575 | n03929660 575 pick 576 | n02965783 576 car_mirror 577 | n04258138 577 solar_dish 578 | n04074963 578 remote_control 579 | n03208938 579 disk_brake 580 | n02910353 580 buckle 581 | n03476684 581 hair_slide 582 | n03627232 582 knot 583 | n03075370 583 combination_lock 584 | n03874599 584 padlock 585 | n03804744 585 nail 586 | n04127249 586 safety_pin 587 | n04153751 587 screw 588 | n03803284 588 muzzle 589 | n04162706 589 seat_belt 590 | n04228054 590 ski 591 | n02948072 591 candle 592 | n03590841 592 jack-o'-lantern 593 | n04286575 593 spotlight 594 | n04456115 594 torch 595 | n03814639 595 neck_brace 596 | n03933933 596 pier 597 | n04485082 597 tripod 598 | n03733131 598 maypole 599 | n03794056 599 mousetrap 600 | n04275548 600 spider_web 601 | n01768244 601 trilobite 602 | n01770081 602 harvestman 603 | n01770393 603 scorpion 604 | n01773157 604 black_and_gold_garden_spider 605 | n01773549 605 barn_spider 606 | n01773797 606 garden_spider 607 | n01774384 607 black_widow 608 | n01774750 608 tarantula 609 | n01775062 609 wolf_spider 610 | n01776313 610 tick 611 | n01784675 611 centipede 612 | n01990800 612 isopod 613 | n01978287 613 Dungeness_crab 614 | n01978455 614 rock_crab 615 | n01980166 615 fiddler_crab 616 | n01981276 616 king_crab 617 | n01983481 617 American_lobster 618 | n01984695 618 spiny_lobster 619 | n01985128 619 crayfish 620 | n01986214 620 hermit_crab 621 | n02165105 621 tiger_beetle 622 | n02165456 622 ladybug 623 | n02167151 623 ground_beetle 624 | n02168699 624 long-horned_beetle 625 | n02169497 625 leaf_beetle 626 | n02172182 626 dung_beetle 627 | n02174001 627 rhinoceros_beetle 628 | n02177972 628 weevil 629 | n02190166 629 fly 630 | n02206856 630 bee 631 | n02226429 631 grasshopper 632 | n02229544 632 cricket 633 | n02231487 633 walking_stick 634 | n02233338 634 cockroach 635 | n02236044 635 mantis 636 | n02256656 636 cicada 637 | n02259212 637 leafhopper 638 | n02264363 638 lacewing 639 | n02268443 639 dragonfly 640 | n02268853 640 damselfly 641 | n02276258 641 admiral 642 | n02277742 642 ringlet 643 | n02279972 643 monarch 644 | n02280649 644 cabbage_butterfly 645 | n02281406 645 sulphur_butterfly 646 | n02281787 646 lycaenid 647 | n01910747 647 jellyfish 648 | n01914609 648 sea_anemone 649 | n01917289 649 brain_coral 650 | n01924916 650 flatworm 651 | n01930112 651 nematode 652 | n01943899 652 conch 653 | n01944390 653 snail 654 | n01945685 654 slug 655 | n01950731 655 sea_slug 656 | n01955084 656 chiton 657 | n02319095 657 sea_urchin 658 | n02321529 658 sea_cucumber 659 | n03584829 659 iron 660 | n03297495 660 espresso_maker 661 | n03761084 661 microwave 662 | n03259280 662 Dutch_oven 663 | n04111531 663 rotisserie 664 | n04442312 664 toaster 665 | n04542943 665 waffle_iron 666 | n04517823 666 vacuum 667 | n03207941 667 dishwasher 668 | n04070727 668 refrigerator 669 | n04554684 669 washer 670 | n03133878 670 Crock_Pot 671 | n03400231 671 frying_pan 672 | n04596742 672 wok 673 | n02939185 673 caldron 674 | n03063689 674 coffeepot 675 | n04398044 675 teapot 676 | n04270147 676 spatula 677 | n02699494 677 altar 678 | n04486054 678 triumphal_arch 679 | n03899768 679 patio 680 | n04311004 680 steel_arch_bridge 681 | n04366367 681 suspension_bridge 682 | n04532670 682 viaduct 683 | n02793495 683 barn 684 | n03457902 684 greenhouse 685 | n03877845 685 palace 686 | n03781244 686 monastery 687 | n03661043 687 library 688 | n02727426 688 apiary 689 | n02859443 689 boathouse 690 | n03028079 690 church 691 | n03788195 691 mosque 692 | n04346328 692 stupa 693 | n03956157 693 planetarium 694 | n04081281 694 restaurant 695 | n03032252 695 cinema 696 | n03529860 696 home_theater 697 | n03697007 697 lumbermill 698 | n03065424 698 coil 699 | n03837869 699 obelisk 700 | n04458633 700 totem_pole 701 | n02980441 701 castle 702 | n04005630 702 prison 703 | n03461385 703 grocery_store 704 | n02776631 704 bakery 705 | n02791270 705 barbershop 706 | n02871525 706 bookshop 707 | n02927161 707 butcher_shop 708 | n03089624 708 confectionery 709 | n04200800 709 shoe_shop 710 | n04443257 710 tobacco_shop 711 | n04462240 711 toyshop 712 | n03388043 712 fountain 713 | n03042490 713 cliff_dwelling 714 | n04613696 714 yurt 715 | n03216828 715 dock 716 | n02892201 716 brass 717 | n03743016 717 megalith 718 | n02788148 718 bannister 719 | n02894605 719 breakwater 720 | n03160309 720 dam 721 | n03000134 721 chainlink_fence 722 | n03930313 722 picket_fence 723 | n04604644 723 worm_fence 724 | n04326547 724 stone_wall 725 | n03459775 725 grille 726 | n04239074 726 sliding_door 727 | n04501370 727 turnstile 728 | n03792972 728 mountain_tent 729 | n04149813 729 scoreboard 730 | n03530642 730 honeycomb 731 | n03961711 731 plate_rack 732 | n03903868 732 pedestal 733 | n02814860 733 beacon 734 | n07711569 734 mashed_potato 735 | n07720875 735 bell_pepper 736 | n07714571 736 head_cabbage 737 | n07714990 737 broccoli 738 | n07715103 738 cauliflower 739 | n07716358 739 zucchini 740 | n07716906 740 spaghetti_squash 741 | n07717410 741 acorn_squash 742 | n07717556 742 butternut_squash 743 | n07718472 743 cucumber 744 | n07718747 744 artichoke 745 | n07730033 745 cardoon 746 | n07734744 746 mushroom 747 | n04209239 747 shower_curtain 748 | n03594734 748 jean 749 | n02971356 749 carton 750 | n03485794 750 handkerchief 751 | n04133789 751 sandal 752 | n02747177 752 ashcan 753 | n04125021 753 safe 754 | n07579787 754 plate 755 | n03814906 755 necklace 756 | n03134739 756 croquet_ball 757 | n03404251 757 fur_coat 758 | n04423845 758 thimble 759 | n03877472 759 pajama 760 | n04120489 760 running_shoe 761 | n03062245 761 cocktail_shaker 762 | n03014705 762 chest 763 | n03717622 763 manhole_cover 764 | n03777754 764 modem 765 | n04493381 765 tub 766 | n04476259 766 tray 767 | n02777292 767 balance_beam 768 | n07693725 768 bagel 769 | n03998194 769 prayer_rug 770 | n03617480 770 kimono 771 | n07590611 771 hot_pot 772 | n04579145 772 whiskey_jug 773 | n03623198 773 knee_pad 774 | n07248320 774 book_jacket 775 | n04277352 775 spindle 776 | n04229816 776 ski_mask 777 | n02823428 777 beer_bottle 778 | n03127747 778 crash_helmet 779 | n02877765 779 bottlecap 780 | n04435653 780 tile_roof 781 | n03724870 781 mask 782 | n03710637 782 maillot 783 | n03920288 783 Petri_dish 784 | n03379051 784 football_helmet 785 | n02807133 785 bathing_cap 786 | n04399382 786 teddy 787 | n03527444 787 holster 788 | n03983396 788 pop_bottle 789 | n03924679 789 photocopier 790 | n04532106 790 vestment 791 | n06785654 791 crossword_puzzle 792 | n03445777 792 golf_ball 793 | n07613480 793 trifle 794 | n04350905 794 suit 795 | n04562935 795 water_tower 796 | n03325584 796 feather_boa 797 | n03045698 797 cloak 798 | n07892512 798 red_wine 799 | n03250847 799 drumstick 800 | n04192698 800 shield 801 | n03026506 801 Christmas_stocking 802 | n03534580 802 hoopskirt 803 | n07565083 803 menu 804 | n04296562 804 stage 805 | n02869837 805 bonnet 806 | n07871810 806 meat_loaf 807 | n02799071 807 baseball 808 | n03314780 808 face_powder 809 | n04141327 809 scabbard 810 | n04357314 810 sunscreen 811 | n02823750 811 beer_glass 812 | n13052670 812 hen-of-the-woods 813 | n07583066 813 guacamole 814 | n03637318 814 lampshade 815 | n04599235 815 wool 816 | n07802026 816 hay 817 | n02883205 817 bow_tie 818 | n03709823 818 mailbag 819 | n04560804 819 water_jug 820 | n02909870 820 bucket 821 | n03207743 821 dishrag 822 | n04263257 822 soup_bowl 823 | n07932039 823 eggnog 824 | n03786901 824 mortar 825 | n04479046 825 trench_coat 826 | n03873416 826 paddle 827 | n02999410 827 chain 828 | n04367480 828 swab 829 | n03775546 829 mixing_bowl 830 | n07875152 830 potpie 831 | n04591713 831 wine_bottle 832 | n04201297 832 shoji 833 | n02916936 833 bulletproof_vest 834 | n03240683 834 drilling_platform 835 | n02840245 835 binder 836 | n02963159 836 cardigan 837 | n04370456 837 sweatshirt 838 | n03991062 838 pot 839 | n02843684 839 birdhouse 840 | n03482405 840 hamper 841 | n03942813 841 ping-pong_ball 842 | n03908618 842 pencil_box 843 | n03902125 843 pay-phone 844 | n07584110 844 consomme 845 | n02730930 845 apron 846 | n04023962 846 punching_bag 847 | n02769748 847 backpack 848 | n10148035 848 groom 849 | n02817516 849 bearskin 850 | n03908714 850 pencil_sharpener 851 | n02906734 851 broom 852 | n03788365 852 mosquito_net 853 | n02667093 853 abaya 854 | n03787032 854 mortarboard 855 | n03980874 855 poncho 856 | n03141823 856 crutch 857 | n03976467 857 Polaroid_camera 858 | n04264628 858 space_bar 859 | n07930864 859 cup 860 | n04039381 860 racket 861 | n06874185 861 traffic_light 862 | n04033901 862 quill 863 | n04041544 863 radio 864 | n07860988 864 dough 865 | n03146219 865 cuirass 866 | n03763968 866 military_uniform 867 | n03676483 867 lipstick 868 | n04209133 868 shower_cap 869 | n03782006 869 monitor 870 | n03857828 870 oscilloscope 871 | n03775071 871 mitten 872 | n02892767 872 brassiere 873 | n07684084 873 French_loaf 874 | n04522168 874 vase 875 | n03764736 875 milk_can 876 | n04118538 876 rugby_ball 877 | n03887697 877 paper_towel 878 | n13044778 878 earthstar 879 | n03291819 879 envelope 880 | n03770439 880 miniskirt 881 | n03124170 881 cowboy_hat 882 | n04487081 882 trolleybus 883 | n03916031 883 perfume 884 | n02808440 884 bathtub 885 | n07697537 885 hotdog 886 | n12985857 886 coral_fungus 887 | n02917067 887 bullet_train 888 | n03938244 888 pillow 889 | n15075141 889 toilet_tissue 890 | n02978881 890 cassette 891 | n02966687 891 carpenter's_kit 892 | n03633091 892 ladle 893 | n13040303 893 stinkhorn 894 | n03690938 894 lotion 895 | n03476991 895 hair_spray 896 | n02669723 896 academic_gown 897 | n03220513 897 dome 898 | n03127925 898 crate 899 | n04584207 899 wig 900 | n07880968 900 burrito 901 | n03937543 901 pill_bottle 902 | n03000247 902 chain_mail 903 | n04418357 903 theater_curtain 904 | n04590129 904 window_shade 905 | n02795169 905 barrel 906 | n04553703 906 washbasin 907 | n02783161 907 ballpoint 908 | n02802426 908 basketball 909 | n02808304 909 bath_towel 910 | n03124043 910 cowboy_boot 911 | n03450230 911 gown 912 | n04589890 912 window_screen 913 | n12998815 913 agaric 914 | n02992529 914 cellular_telephone 915 | n03825788 915 nipple 916 | n02790996 916 barbell 917 | n03710193 917 mailbox 918 | n03630383 918 lab_coat 919 | n03347037 919 fire_screen 920 | n03769881 920 minibus 921 | n03871628 921 packet 922 | n03733281 922 maze 923 | n03976657 923 pole 924 | n03535780 924 horizontal_bar 925 | n04259630 925 sombrero 926 | n03929855 926 pickelhaube 927 | n04049303 927 rain_barrel 928 | n04548362 928 wallet 929 | n02979186 929 cassette_player 930 | n06596364 930 comic_book 931 | n03935335 931 piggy_bank 932 | n06794110 932 street_sign 933 | n02825657 933 bell_cote 934 | n03388183 934 fountain_pen 935 | n04591157 935 Windsor_tie 936 | n04540053 936 volleyball 937 | n03866082 937 overskirt 938 | n04136333 938 sarong 939 | n04026417 939 purse 940 | n02865351 940 bolo_tie 941 | n02834397 941 bib 942 | n03888257 942 parachute 943 | n04235860 943 sleeping_bag 944 | n04404412 944 television 945 | n04371430 945 swimming_trunks 946 | n03733805 946 measuring_cup 947 | n07920052 947 espresso 948 | n07873807 948 pizza 949 | n02895154 949 breastplate 950 | n04204238 950 shopping_basket 951 | n04597913 951 wooden_spoon 952 | n04131690 952 saltshaker 953 | n07836838 953 chocolate_sauce 954 | n09835506 954 ballplayer 955 | n03443371 955 goblet 956 | n13037406 956 gyromitra 957 | n04336792 957 stretcher 958 | n04557648 958 water_bottle 959 | n03187595 959 dial_telephone 960 | n04254120 960 soap_dispenser 961 | n03595614 961 jersey 962 | n04146614 962 school_bus 963 | n03598930 963 jigsaw_puzzle 964 | n03958227 964 plastic_bag 965 | n04069434 965 reflex_camera 966 | n03188531 966 diaper 967 | n02786058 967 Band_Aid 968 | n07615774 968 ice_lolly 969 | n04525038 969 velvet 970 | n04409515 970 tennis_ball 971 | n03424325 971 gasmask 972 | n03223299 972 doormat 973 | n03680355 973 Loafer 974 | n07614500 974 ice_cream 975 | n07695742 975 pretzel 976 | n04033995 976 quilt 977 | n03710721 977 maillot 978 | n04392985 978 tape_player 979 | n03047690 979 clog 980 | n03584254 980 iPod 981 | n13054560 981 bolete 982 | n10565667 982 scuba_diver 983 | n03950228 983 pitcher 984 | n03729826 984 matchstick 985 | n02837789 985 bikini 986 | n04254777 986 sock 987 | n02988304 987 CD_player 988 | n03657121 988 lens_cap 989 | n04417672 989 thatch 990 | n04523525 990 vault 991 | n02815834 991 beaker 992 | n09229709 992 bubble 993 | n07697313 993 cheeseburger 994 | n03888605 994 parallel_bars 995 | n03355925 995 flagpole 996 | n03063599 996 coffee_mug 997 | n04116512 997 rubber_eraser 998 | n04325704 998 stole 999 | n07831146 999 carbonara 1000 | n03255030 1000 dumbbell -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/hash_net/generate_random_dataset.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import torch 3 | from tqdm import tqdm 4 | import random 5 | import os 6 | from sklearn.preprocessing import normalize 7 | 8 | 9 | def get2diff_below(number): 10 | """ 11 | 12 | :param low: include low 13 | :param high: include high 14 | :return: two different number 15 | """ 16 | first = random.randint(0, number - 1) 17 | offset = random.randint(1, number - 1) 18 | second = (first + offset) % number 19 | return first + 1, second + 1 20 | 21 | 22 | feature_map = {} 23 | for i in range(1, 31): 24 | feature_map[i] = np.load("../../feature/train/" + str(i) + ".npy") 25 | 26 | pos1 = [] 27 | pos2 = [] 28 | neg = [] 29 | 30 | for i in tqdm(range(10000)): 31 | cate1, cate2 = get2diff_below(30) 32 | 33 | cate1_list = feature_map[cate1] 34 | cate2_list = feature_map[cate2] 35 | 36 | cate1_len = len(cate1_list) 37 | cate2_len = len(cate2_list) 38 | 39 | cate1_line = random.randint(1, cate1_len) 40 | cate2_line1, cate2_line2 = get2diff_below(cate2_len) 41 | 42 | cate1_line_tensor = cate1_list[cate1_line - 1] 43 | 44 | cate2_line1_tensor = cate2_list[cate2_line1 - 1] 45 | cate2_line2_tensor = cate2_list[cate2_line2 - 1] 46 | # print(cate2_line1_tensor.shape) 47 | 48 | pos1.append(cate2_line1_tensor /np.linalg.norm(cate2_line1_tensor)) 49 | pos2.append(cate2_line2_tensor/np.linalg.norm(cate2_line2_tensor)) 50 | neg.append(cate1_line_tensor/np.linalg.norm(cate1_line_tensor)) 51 | 52 | try: 53 | os.remove('../../feature/generated_dataset/pos1_fea.pt') 54 | except: 55 | pass 56 | try: 57 | os.remove('../../feature/generated_dataset/pos2_fea.pt') 58 | except: 59 | pass 60 | try: 61 | os.remove('../../feature/generated_dataset/neg_fea.pt') 62 | except: 63 | pass 64 | 65 | with open('../../feature/generated_dataset/pos1_fea.pt', 'wb') as f: 66 | torch.save(pos1, f) 67 | with open('../../feature/generated_dataset/pos2_fea.pt', 'wb') as f: 68 | torch.save(pos2, f) 69 | with open('../../feature/generated_dataset/neg_fea.pt', 'wb') as f: 70 | torch.save(neg, f) 71 | -------------------------------------------------------------------------------- /triplet-deep-hash-pytorch/src/hash_net/hashNet.py: -------------------------------------------------------------------------------- 1 | # coding=utf-8 2 | 3 | import torch.nn as nn 4 | import math, os, time, random 5 | import torch.utils.model_zoo as model_zoo 6 | import argparse 7 | import torch 8 | import torch.nn.functional as F 9 | import torch.optim as optim 10 | from torchvision import datasets, transforms 11 | from torch.autograd import Variable 12 | from tqdm import tqdm 13 | 14 | parser = argparse.ArgumentParser(description='hashNet') 15 | parser.add_argument('--batch-size', type=int, default=64) 16 | parser.add_argument('--test-batch-size', type=int, default=1000) 17 | parser.add_argument('--epochs', type=int, default=10) 18 | parser.add_argument('--lr', type=float, default=0.01) 19 | parser.add_argument('--momentum', type=float, default=0.4) 20 | parser.add_argument('--no-cuda', action='store_true', default=False) 21 | parser.add_argument('--seed', type=int, default=1) 22 | parser.add_argument('--log-interval', type=int, default=3) 23 | 24 | args = parser.parse_args() 25 | args.cuda = not args.no_cuda and torch.cuda.is_available() 26 | 27 | torch.manual_seed(args.seed) 28 | if args.cuda: 29 | torch.cuda.manual_seed(args.seed) 30 | 31 | # print(args.batch_size) 32 | 33 | kwargs = {'num_worker': 1, 'pin_memory': True} if args.cuda else {} 34 | 35 | 36 | class HashNet(nn.Module): 37 | def __init__(self, in_channel=1536, hashLength=1024): 38 | super(HashNet, self).__init__() 39 | self.fc = nn.Linear(in_channel, hashLength) 40 | self.sm = nn.Sigmoid() 41 | self.sma = nn.Softmax() 42 | self.initLinear() 43 | print(self.fc.weight.data) 44 | 45 | def forward(self, x1, x2, y): 46 | # x1 = self.sm(self.fc(self.sma(x1))) 47 | # x2 = self.sm(self.fc(self.sma(x2))) 48 | # y = self.sm(self.fc(self.sma(y))) 49 | 50 | # x1 = self.sm(self.fc(x1)) 51 | # x2 = self.sm(self.fc(x2)) 52 | # y = self.sm(self.fc(y)) 53 | 54 | x1 = F.selu(self.fc(self.sma(x1))) 55 | x2 = F.selu(self.fc(self.sma(x2))) 56 | y = F.selu(self.fc(self.sma(y))) 57 | return x1, x2, y 58 | 59 | def initLinear(self): 60 | self.fc.weight.data.normal_(1.0, 0.33) 61 | self.fc.bias.data.fill_(0.1) 62 | 63 | 64 | model = HashNet(in_channel=1536, hashLength=8192) 65 | 66 | if args.cuda: 67 | model.cuda() 68 | optimizer = optim.SGD(model.parameters(), lr=args.lr, momentum=args.momentum) 69 | pdist = nn.PairwiseDistance(2) 70 | 71 | 72 | def train(epochs): 73 | model.train() 74 | pos1 = torch.load(open('../../feature/generated_dataset/pos1_fea.pt', 'rb')) 75 | pos2 = torch.load(open('../../feature/generated_dataset/pos2_fea.pt', 'rb')) 76 | neg = torch.load(open('../../feature/generated_dataset/neg_fea.pt', 'rb')) 77 | 78 | # print(pos1) 79 | # print(pos2) 80 | # print(neg) 81 | 82 | length = len(pos1) 83 | print(length) 84 | 85 | for epoch in range(epochs): 86 | for index in range(length): 87 | x1, x2, y = torch.FloatTensor(pos1[index]).view(1,-1), \ 88 | torch.FloatTensor(pos2[index]).view(1,-1), \ 89 | torch.FloatTensor(neg[index]).view(1,-1) 90 | # x1, x2, y = pos1[index],pos2[index],neg[index] 91 | # print('---------') 92 | # print(x1, x2, y) 93 | # print('---------') 94 | # x1 = x1.contiguous().view(1,3,28,28) 95 | # x2 = x2.contiguous().view(1,3,28,28) 96 | # y = y.contiguous().view(1,3,28,28) 97 | # print('---------') 98 | # print(batch_idx, x1, x2, y) 99 | # print('---------') 100 | 101 | # x1.type(torch.FloatTensor) 102 | # x2.type(torch.FloatTensor) 103 | # y.type(torch.FloatTensor) 104 | if args.cuda: 105 | x1, x2, y = x1.cuda(), x2.cuda(), y.cuda() 106 | x1, x2, y = Variable(x1), Variable(x2), Variable(y) 107 | optimizer.zero_grad() 108 | hash_x1, hash_x2, hash_y = model(x1, x2, y) 109 | loss1 = pdist(hash_x1, hash_x2) 110 | loss2 = pdist(hash_x1, hash_y) 111 | l = 10 - loss2 + loss1 112 | loss = F.relu(l) 113 | loss.backward() 114 | optimizer.step() 115 | if index % args.log_interval == 0: 116 | # print('Train Epoch: {} [{}/{} ({:.0f}%)]\tLoss: {:.6f}'.format( 117 | # epoch, index , 1000, 100.0 * index / 1000, 118 | # loss.data[0])) 119 | print("==============================================") 120 | print("total loss=", loss.data[0]) 121 | print("x1==",x1.data,'x2==',x2.data,'y==',y.data) 122 | print("hashx1=",hash_x1,"hashx2=",hash_x2,'hashy=',hash_y) 123 | print('loss1==', loss1.data[0][0], 'loss2==', loss2.data[0][0]) 124 | # time.sleep(5) 125 | torch.save(model.state_dict(), '../../model/hashNetInceptionv4-epoch' + str(epoch) + '.pth') 126 | 127 | 128 | if __name__ == '__main__': 129 | train(1) 130 | --------------------------------------------------------------------------------