{"id":13692991,"url":"https://github.com/clovaai/CutMix-PyTorch","last_synced_at":"2025-05-02T21:30:52.401Z","repository":{"id":49402890,"uuid":"189136525","full_name":"clovaai/CutMix-PyTorch","owner":"clovaai","description":"Official Pytorch implementation of CutMix regularizer","archived":false,"fork":false,"pushed_at":"2020-09-16T03:47:45.000Z","size":203,"stargazers_count":1223,"open_issues_count":6,"forks_count":159,"subscribers_count":16,"default_branch":"master","last_synced_at":"2024-10-30T06:50:50.754Z","etag":null,"topics":["augmentation","cutmix","iccv2019","regularization","transfer-learning"],"latest_commit_sha":null,"homepage":"","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/clovaai.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}},"created_at":"2019-05-29T02:32:07.000Z","updated_at":"2024-10-28T12:05:51.000Z","dependencies_parsed_at":"2022-08-12T20:11:21.006Z","dependency_job_id":null,"html_url":"https://github.com/clovaai/CutMix-PyTorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FCutMix-PyTorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FCutMix-PyTorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FCutMix-PyTorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clovaai%2FCutMix-PyTorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clovaai","download_url":"https://codeload.github.com/clovaai/CutMix-PyTorch/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":224333063,"owners_count":17293975,"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":["augmentation","cutmix","iccv2019","regularization","transfer-learning"],"created_at":"2024-08-02T17:01:04.239Z","updated_at":"2024-11-12T19:30:14.318Z","avatar_url":"https://github.com/clovaai.png","language":"Python","readme":"## Accepted at ICCV 2019 (oral talk) !!\r\n\r\n## CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features\r\n\r\nOfficial Pytorch implementation of CutMix regularizer | [Paper](https://arxiv.org/abs/1905.04899) | [Pretrained Models](#experiments)\r\n\r\n**[Sangdoo Yun](mailto:sangdoo.yun@navercorp.com), Dongyoon Han, Seong Joon Oh, Sanghyuk Chun, Junsuk Choe, Youngjoon Yoo.**\r\n \r\nClova AI Research, NAVER Corp.\r\n\r\nOur implementation is based on these repositories:\r\n- [PyTorch ImageNet Example](https://github.com/pytorch/examples/tree/master/imagenet)\r\n- [PyramidNet-PyTorch](https://github.com/dyhan0920/PyramidNet-PyTorch)\r\n\r\n\r\n### Abstract\r\nRegional dropout strategies have been proposed to enhance the performance of convolutional neural network classifiers. \r\nThey have proved to be effective for guiding the model to attend on less discriminative parts of objects \r\n(e.g. leg as opposed to head of a person), thereby letting the network generalize better and have better object localization capabilities.\r\nOn the other hand, current methods for regional dropout removes informative pixels on training images by overlaying a patch of either black pixels or random noise. \r\nSuch removal is not desirable because it leads to information loss and inefficiency during training.\r\nWe therefore propose the **CutMix** augmentation strategy: patches are cut and pasted among training images where the ground truth labels are also mixed proportionally to the area of the patches.\r\nBy making efficient use of training pixels and retaining the regularization effect of regional dropout, CutMix consistently outperforms the state-of-the-art augmentation strategies on CIFAR and ImageNet classification tasks, as well as on the ImageNet weakly-supervised localization task.\r\nMoreover, unlike previous augmentation methods, our CutMix-trained ImageNet classifier, when used as a pretrained model, results in consistent performance gains in Pascal detection and MS-COCO image captioning benchmarks.\r\nWe also show that CutMix improves the model robustness against input corruptions and its out-of-distribution detection performances.\r\n\r\n\r\n### Overview of the results of Mixup, Cutout, and CutMix. \r\n\r\n\u003cimg width=\"600\" alt=\"teaser\" src=\"./img1.PNG\"\u003e\r\n\r\n## Updates\r\n**23 May, 2019**: Initial upload\r\n\r\n## Getting Started\r\n### Requirements\r\n- Python3\r\n- PyTorch (\u003e 1.0)\r\n- torchvision (\u003e 0.2)\r\n- NumPy\r\n\r\n### Train Examples\r\n- CIFAR-100: We used 2 GPUs to train CIFAR-100.\r\n```\r\npython train.py \\\r\n--net_type pyramidnet \\\r\n--dataset cifar100 \\\r\n--depth 200 \\\r\n--alpha 240 \\\r\n--batch_size 64 \\\r\n--lr 0.25 \\\r\n--expname PyraNet200 \\\r\n--epochs 300 \\\r\n--beta 1.0 \\\r\n--cutmix_prob 0.5 \\\r\n--no-verbose\r\n```\r\n- ImageNet: We used 4 GPUs to train ImageNet. \r\n```\r\npython train.py \\\r\n--net_type resnet \\\r\n--dataset imagenet \\\r\n--batch_size 256 \\\r\n--lr 0.1 \\\r\n--depth 50 \\\r\n--epochs 300 \\\r\n--expname ResNet50 \\\r\n-j 40 \\\r\n--beta 1.0 \\\r\n--cutmix_prob 1.0 \\\r\n--no-verbose\r\n```\r\n\r\n### Test Examples using Pretrained model\r\n- Download [CutMix-pretrained PyramidNet200 (top-1 error: 14.23)](https://www.dropbox.com/sh/o68qbvayptt2rz5/AACy3o779BxoRqw6_GQf_QFQa?dl=0) \r\n```\r\npython test.py \\\r\n--net_type pyramidnet \\\r\n--dataset cifar100 \\\r\n--batch_size 64 \\\r\n--depth 200 \\\r\n--alpha 240 \\\r\n--pretrained /set/your/model/path/model_best.pth.tar\r\n```\r\n- Download [CutMix-pretrained ResNet50 (top-1 error: 21.40)](https://www.dropbox.com/sh/w8dvfgdc3eirivf/AABnGcTO9wao9xVGWwqsXRala?dl=0)\r\n```\r\npython test.py \\\r\n--net_type resnet \\\r\n--dataset imagenet \\\r\n--batch_size 64 \\\r\n--depth 50 \\\r\n--pretrained /set/your/model/path/model_best.pth.tar\r\n```\r\n\r\n\u003ch2 id=\"experiments\"\u003eExperimental Results and Pretrained Models\u003c/h2\u003e\r\n\r\n- PyramidNet-200 pretrained on CIFAR-100 dataset:\r\n\r\nMethod | Top-1 Error | Model file\r\n-- | -- | --\r\nPyramidNet-200 [[CVPR'17](https://arxiv.org/abs/1610.02915)] (baseline) | 16.45 | [model](https://www.dropbox.com/sh/6rfew3lr761jq6c/AADrdQOXNx5tWmgOSnAw9NEVa?dl=0)\r\nPyramidNet-200 + **CutMix** | **14.23** | [model](https://www.dropbox.com/sh/o68qbvayptt2rz5/AACy3o779BxoRqw6_GQf_QFQa?dl=0)\r\nPyramidNet-200 + Shakedrop [[arXiv'18](https://arxiv.org/abs/1802.02375)] + **CutMix**  | **13.81** | -\r\nPyramidNet-200 + Mixup [[ICLR'18](https://arxiv.org/abs/1710.09412)] | 15.63 | [model](https://www.dropbox.com/sh/g55jnsv62v0n59s/AAC9LPg-LjlnBn4ttKs6vr7Ka?dl=0)\r\nPyramidNet-200 + Manifold Mixup [[ICML'19](https://arxiv.org/abs/1806.05236)] | 16.14 | [model](https://www.dropbox.com/sh/nngw7hhk1e8msbr/AABkdCsP0ABnQJDBX7LQVj4la?dl=0)\r\nPyramidNet-200 + Cutout [[arXiv'17](https://arxiv.org/abs/1708.04552)] | 16.53 | [model](https://www.dropbox.com/sh/ajjz4q8c8t6qva9/AAAeBGb2Q4TnJMW0JAzeVSpfa?dl=0)\r\nPyramidNet-200 + DropBlock [[NeurIPS'18](https://arxiv.org/abs/1810.12890)] | 15.73 | [model](https://www.dropbox.com/sh/vefjo960gyrsx2i/AACYA5wOJ_yroNjIjdsN1Dz2a?dl=0)\r\nPyramidNet-200 + Cutout + Labelsmoothing | 15.61 | [model](https://www.dropbox.com/sh/1mur0kjcfxdn7jn/AADmghqrj0dXAG0qY1v3Csb6a?dl=0)\r\nPyramidNet-200 + DropBlock + Labelsmoothing | 15.16 | [model](https://www.dropbox.com/sh/n1dn6ggyxjcoogc/AADpSSNzvaraSCqWtHBE0qMca?dl=0)\r\nPyramidNet-200 + Cutout + Mixup | 15.46 | [model](https://www.dropbox.com/sh/5run1sx8oy0v9oi/AACiR_wEBQVp2HMZFx6lGl3ka?dl=0)\r\n\r\n\r\n- ResNet models pretrained on ImageNet dataset:\r\n\r\nMethod | Top-1 Error | Model file\r\n-- | -- | --\r\nResNet-50 [[CVPR'16](https://arxiv.org/abs/1512.03385)] (baseline) | 23.68 | [model](https://www.dropbox.com/sh/phwbbrtadrclpnx/AAA9QUW9G_xvBdI-mDiIzP_Ha?dl=0)\r\nResNet-50 + **CutMix** | **21.40** | [model](https://www.dropbox.com/sh/w8dvfgdc3eirivf/AABnGcTO9wao9xVGWwqsXRala?dl=0)\r\nResNet-50 + **Feature CutMix** | **21.80** | [model](https://www.dropbox.com/sh/zj1wptsg0hwqf0k/AABRNzvjFmIS7_vOEQkqb6T4a?dl=0)\r\nResNet-50 + Mixup [[ICLR'18](https://arxiv.org/abs/1710.09412)] | 22.58 | [model](https://www.dropbox.com/sh/g64c8bda61n12if/AACyaTZnku_Sgibc9UvOSblNa?dl=0)\r\nResNet-50 + Manifold Mixup [[ICML'19](https://arxiv.org/abs/1806.05236)] | 22.50 | [model](https://www.dropbox.com/sh/bjardjje11pti0g/AABFGW0gNrNE8o8TqUf4-SYSa?dl=0)\r\nResNet-50 + Cutout [[arXiv'17](https://arxiv.org/abs/1708.04552)] | 22.93 | [model](https://www.dropbox.com/sh/ln8zk2z7zt2h1en/AAA7z8xTBlzz7Ofbd5L7oTnTa?dl=0)\r\nResNet-50 + AutoAugment [[CVPR'19](https://arxiv.org/abs/1805.09501)] | 22.40* | -\r\nResNet-50 + DropBlock [[NeurIPS'18](https://arxiv.org/abs/1810.12890)] | 21.87* | -\r\nResNet-101 + **CutMix** | **20.17** | [model](https://www.dropbox.com/sh/1z4xnp9nwdmpzb5/AACQX4KU8XkTN0JSTfjkCktNa?dl=0)\r\nResNet-152 + **CutMix** | **19.20** | [model](https://www.dropbox.com/s/6vq1mzy27z8qxko/resnet152_cutmix_acc_80_80.pth?dl=0)\r\nResNeXt-101 (32x4d) + **CutMix** | **19.47** | [model](https://www.dropbox.com/s/maysvgopsi17qi0/resnext_cutmix.pth.tar?dl=0)\r\n\r\n\\* denotes results reported in the original papers\r\n\r\n## Transfer Learning Results\r\n\r\nBackbone | ImageNet Cls (%) | ImageNet Loc (%) | CUB200 Loc (%) | Detection (SSD) (mAP) | Detection (Faster-RCNN) (mAP) | Image Captioning (BLEU-4)\r\n-- | -- | -- | -- | -- | -- | --\r\nResNet50 | 23.68 | 46.3 | 49.41 | 76.7 | 75.6 | 22.9\r\nResNet50+Mixup | 22.58 | 45.84 | 49.3 | 76.6 | 73.9 | 23.2\r\nResNet50+Cutout | 22.93 | 46.69 | 52.78 | 76.8 | 75 | 24.0\r\nResNet50+**CutMix** | **21.60** | **46.25** | **54.81** | **77.6** | **76.7** | **24.9**\r\n\r\n\r\n## Third-party Implementations \r\n- [Pytorch-CutMix](https://github.com/hysts/pytorch_cutmix) by @hysts\r\n- [TensorFlow-CutMix](https://github.com/jis478/Tensorflow/tree/master/TF2.0/Cutmix) by @jis478\r\n\r\n## Citation\r\n```\r\n@inproceedings{yun2019cutmix,\r\n    title={CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features},\r\n    author={Yun, Sangdoo and Han, Dongyoon and Oh, Seong Joon and Chun, Sanghyuk and Choe, Junsuk and Yoo, Youngjoon},\r\n    booktitle = {International Conference on Computer Vision (ICCV)},\r\n    year={2019},\r\n    pubstate={published},\r\n    tppubtype={inproceedings}\r\n}\r\n```\r\n\r\n## License\r\n```\r\nCopyright (c) 2019-present NAVER Corp.\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining a copy\r\nof this software and associated documentation files (the \"Software\"), to deal\r\nin the Software without restriction, including without limitation the rights\r\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\r\ncopies of the Software, and to permit persons to whom the Software is\r\nfurnished to do so, subject to the following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be included in\r\nall copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE\r\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\r\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\r\nTHE SOFTWARE.\r\n```\r\n","funding_links":[],"categories":["Table of Contents","Python","DeepCNN","Repos"],"sub_categories":["Sample Mixup Policies in SL","Training"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclovaai%2FCutMix-PyTorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclovaai%2FCutMix-PyTorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclovaai%2FCutMix-PyTorch/lists"}