{"id":16585527,"url":"https://github.com/jdhao/deep_firearm","last_synced_at":"2025-07-01T13:07:01.780Z","repository":{"id":109573863,"uuid":"135985660","full_name":"jdhao/deep_firearm","owner":"jdhao","description":"This repo is used to host our code for the work of deep firearm image retrieval.","archived":false,"fork":false,"pushed_at":"2020-03-31T15:58:43.000Z","size":18,"stargazers_count":11,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-27T15:11:40.481Z","etag":null,"topics":["double-margin-contrastive-loss","image-retrieval","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdhao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-04T07:15:29.000Z","updated_at":"2025-02-26T22:33:58.000Z","dependencies_parsed_at":"2023-03-30T08:39:22.604Z","dependency_job_id":null,"html_url":"https://github.com/jdhao/deep_firearm","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/jdhao/deep_firearm","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhao%2Fdeep_firearm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhao%2Fdeep_firearm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhao%2Fdeep_firearm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhao%2Fdeep_firearm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdhao","download_url":"https://codeload.github.com/jdhao/deep_firearm/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdhao%2Fdeep_firearm/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262969886,"owners_count":23392529,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["double-margin-contrastive-loss","image-retrieval","pytorch"],"created_at":"2024-10-11T22:48:18.137Z","updated_at":"2025-07-01T13:07:01.772Z","avatar_url":"https://github.com/jdhao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Introduction\n\nThis is the code our ICPR2018 paper \"[DeepFirearm: Learning Discriminative\nFeature Representation for Fine-grained Firearm\nRetrieval](https://arxiv.org/abs/1806.02984)\".\n\n\n# How to run the code\n\n## Version info\n\nThe code is written using the PyTorch version 0.3.0. So In order to run this\ncode, you may install version 0.3.0 of PyTorch or adapt it to the newer version\nof PyTorch.\n\n## Instructions for downloading dataset\n\nYou can download the dataset from\n[here](https://drive.google.com/drive/folders/1BucERZl51nB20ssxGsQrcT6l59MNLkf7).\nTwo separate data are used for the experiment. One is for classification\ntraining, and the other is for the retrieval training. After downloading this\ndataset, extract it under the folder `data` using the following commands:\n\n```bash\ntar -zxvf firearm-train-val.tar.gz -C data/ # for the classification data\n```\n\nand\n\n```bash\ntar -zxvf firearm-dataset.tar.gz -C data/ # for the retrieval data\n```\n\n## Train the classification model\n\nIn order to train the classification model, run the following command:\n\n```bash\npython train_cls.py\n```\n\n## Train the retrieval model after classification\n\nTo get better retrieval performance, we further fine-tune the model using\nretrieval task based on the classification model. To train the model, use the\nfollowing command:\n\n```bash\npython train_retr_from_cls.py\n```\n\n## Benchmark on test set\n\nTo check the model's performance on test set, run the following command:\n\n```python\npython benchmark_on_test.py\n```\n\nIt will show both the mAP and rank-k accuracy for different feature dimensions.\n\n# Citation information\n\nIf you use this dataset or use our code, please cite the following work:\n\n```\n@INPROCEEDINGS{HJD2018DFLD,\nauthor={J. Hao and J. Dong and W. Wang and T. Tan},\nbooktitle={2018 24th International Conference on Pattern Recognition (ICPR)},\ntitle={DeepFirearm: Learning Discriminative Feature Representation for Fine-grained Firearm Retrieval},\nyear={2018},\nvolume={},\nnumber={},\npages={3335-3340},\nkeywords={feature extraction;feedforward neural nets;image classification;image representation;image retrieval;learning (artificial intelligence);convolutional neural networks;single margin contrastive loss;firearm images;double margin contrastive loss;negative image pairs;positive image pairs;fine-grained recognition;Firearm 14k;image retrieval techniques;social media;fine-grained Firearm retrieval;discriminative feature representation;Training;Task analysis;Labeling;Correlation;Image retrieval;Forensics;Convolutional neural networks},\ndoi={10.1109/ICPR.2018.8545529},\nISSN={1051-4651},\nmonth={Aug},}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhao%2Fdeep_firearm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdhao%2Fdeep_firearm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdhao%2Fdeep_firearm/lists"}