{"id":20990639,"url":"https://github.com/wnjxyk/decoop","last_synced_at":"2025-07-21T16:32:46.187Z","repository":{"id":241925472,"uuid":"799595746","full_name":"WNJXYK/DeCoOp","owner":"WNJXYK","description":null,"archived":false,"fork":false,"pushed_at":"2024-06-04T06:49:26.000Z","size":5004,"stargazers_count":14,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-12T04:52:40.713Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/WNJXYK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-05-12T15:58:26.000Z","updated_at":"2025-03-03T11:27:29.000Z","dependencies_parsed_at":"2024-06-04T07:57:52.855Z","dependency_job_id":null,"html_url":"https://github.com/WNJXYK/DeCoOp","commit_stats":null,"previous_names":["wnjxyk/decoop"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/WNJXYK/DeCoOp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WNJXYK%2FDeCoOp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WNJXYK%2FDeCoOp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WNJXYK%2FDeCoOp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WNJXYK%2FDeCoOp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/WNJXYK","download_url":"https://codeload.github.com/WNJXYK/DeCoOp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/WNJXYK%2FDeCoOp/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266334306,"owners_count":23912940,"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","status":"online","status_checked_at":"2025-07-21T11:47:31.412Z","response_time":64,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-19T06:34:49.156Z","updated_at":"2025-07-21T16:32:46.128Z","avatar_url":"https://github.com/WNJXYK.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# DeCoOp: Robust Prompt Tuning with Out-of-Distribution Detection\n\n\u003cp align=\"center\"\u003e\n🏠 \u003ca href=\"https://wnjxyk.github.io/DeCoOp\" target=\"_blank\"\u003eHomepage\u003c/a\u003e • 📃 \u003ca href=\"https://arxiv.org/abs/2406.00345\" target=\"_blank\"\u003ePaper\u003c/a\u003e\u003cbr\u003e\n\u003c/p\u003e\n\n## OPT Problem Setting\n\n![OPT](https://zhouz.dev/DeCoOp/static/images/setting-wide.png)\n\nIn this paper, we examine a problem setting known as \n***O**pen-world **P**rompt **T**uning* \n(OPT), which focuses on tuning prompts for base classes and evaluating their performance on a combination of base and new classes. This setting allows for a comprehensive evaluation of the discriminabilities among the base-class, base-to-new, and new-class categories. We demonstrate that the accuracy in OPT does not align consistently with the previous H metric, as shown in the figure in our paper, indicating the need for a new evaluation metric for OPT.\n\n## DeCoOp Approach\n\n![DeCoOp](https://zhouz.dev/DeCoOp/static/images/method.png)\n\nWe propose the \n***De**composed **Co**ntext **Op**timization* \n(DeCoOp) approach to solve the OPT problem setting. DeCoOp integrates out-of-distribution (OOD) detection into prompt tuning, introducing new-class detectors to enhance the discriminability between the base and new classes. Additionally, DeCoOp employs sub-classifiers to further enhance the discriminability within the base class, thereby improving the performance of the base-class data. The original prompts are retained to ensure the robust performance of the new-class data. To address the issue of not having knowledge of the new-class data during training, we introduce an ensemble strategy to train the DeCoOp approach. The experimental results demonstrate that our DeCoOp approach surpasses state-of-the-art methods, effectively solving the OPT problem setting.\n\n## Quick Start\n\n### 1. Prepare datasets\n\nPrepare the datasets according to the instructions in [DATASETS](https://github.com/KaiyangZhou/CoOp/blob/main/DATASETS.md) and put them in the `DATA` directory.\n\n### 2. Prepare Python Environment\n\nClone DeCoOp repository, create conda environment, and then install the required packages.\n\n```bash\ngit clone https://github.com/WNJXYK/DeCoOp.git\ncd DeCoOp\nconda create -n decoop python==3.8\nconda activate decoop\npip install -r requirements.txt\n```\n\n### 3. Run DeCoOp Approach\n\nRun the DeCoOp approach using the command script `bash eval_decoop.sh {GpuID} {Architecture} {Logdir}`, where `GpuID` is an integer indicating the GPU you want to use, `Architecture` is the backbone model of CLIP with options Vit-B16 or Vit-B32, and `Logdir` is the path to save the experimental results.\n\nFor example, to run DeCoOp using GPU 0 and the Vit-B16 backbone model, with the corresponding experimental logs saved to `./results`, use the following command:\n\n```bash\nbash eval_decoop.sh 0 Vit-B16 ./results\n```\n\n## TODO List\n\n- [x] Launch project homepage\n- [x] Release official code\n- [ ] Release code based on Dassl.pytorch toolbox\n\n## Citation\n\nPlease cite the paper if you refer to our code or paper from DeCoOp.\n\n```plain\n@inproceedings{zhou24decoop,\n    author       = {Zhi Zhou and Ming Yang and Jiang-Xin Shi and Lan-Zhe Guo and Yu-Feng Li},\n    title        = {DeCoOp: Robust Prompt Tuning with Out-of-Distribution Detection},\n    booktitle    = {Proceedings of the 41st International Conference on Machine Learning},\n    year         = {2024}\n}\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnjxyk%2Fdecoop","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwnjxyk%2Fdecoop","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwnjxyk%2Fdecoop/lists"}