• Stars
    star
    167
  • Rank 226,635 (Top 5 %)
  • Language
    Python
  • License
    MIT License
  • Created over 5 years ago
  • Updated about 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

a Ready-to-use PyTorch Extension of Unofficial CutMix Implementations with more improved performance.

cutmix

a Ready-to-use PyTorch Extension of Unofficial CutMix Implementations.

This re-implementation is improved in some parts,

  • Fixing issue #1 in the original repository
  • issue #3 : Random crop regions are randomly chosen, even within the same batch.
  • issue #4 : Different lambda values(sizes of crop regions) are randomly chosen, even within the same batch.
  • Images to be cropped are randomly chosen in the whole dataset. Original implementation selects images only inside the same batch(shuffling).
  • Easy to install and use on your existing project.
  • With additional augmentations(fast-autoaugment), the performances are improved further.

Hence, there may be slightly-improved training results also.

Requirements

  • python3
  • torch >= 1.1.0

Install

This repository is pip-installable,

$ pip install git+https://github.com/ildoonet/cutmix

or you can copy 'cutmix' folder to your project to use it.

Usage

Our CutMix is inhereted from the PyTorch Dataset class so you can wrap your own dataset(eg. cifar10, imagenet, ...). Also we provide CutMixCrossEntropyLoss, soft version of cross-entropy loss, which accept soft-labels required by cutmix.

from cutmix.cutmix import CutMix
from cutmix.utils import CutMixCrossEntropyLoss
...

dataset = datasets.CIFAR100(args.cifarpath, train=True, download=True, transform=transform_train)
dataset = CutMix(dataset, num_class=100, beta=1.0, prob=0.5, num_mix=2)    # this is paper's original setting for cifar.
...

criterion = CutMixCrossEntropyLoss(True)
for _ in range(num_epoch):
    for input, target in loader:    # input is cutmixed image's normalized tensor and target is soft-label which made by mixing 2 or more labels.
        output = model(input)
        loss = criterion(output, target)
    
        loss.backward()
        optimizer.step()
        optimizer.zero_grad()

Result

PyramidNet-200 + ShakeDrop + CutMix \w CIFAR-100

Top-1 Error(@300epoch) Top-1 Error(Best) Model File
Paper's Reported Result N/A 13.81 N/A
Our Re-implementation 13.68 13.15 Download(12.88)
+ Fast AutoAugment 13.3 12.95

We ran 6 indenpendent experiments with our re-implemented codes and got top-1 errors of 13.09, 13.29, 13.27, 13.24, 13.15 and 12.88, using below command. (Converged at 300epoch with the top-1 errors of 13.55, 13.66, 13.95, 13.9, 13.8 and 13.32.)

$ python train.py -c conf/cifar100_pyramid200.yaml

ResNet + CutMix \w ImageNet

Top-1 Error
(@300epoch)
Top-1 Error
(Best)
Model File
ResNet18 Reported Result \wo CutMix N/A 30.43
Ours 29.674 29.56
ResNet34 Reported Result \wo CutMix N/A 26.456
Ours 24.7 24.57 Download
ResNet50 Paper's Reported Result N/A 21.4 N/A
Author's Code(Our Re-run) 21.768 21.586 N/A
Our Re-implementation 21.524 21.340 Download(21.25)
ResNet200 Our Re-implementation
+ Fast AutoAugment 19.058 18.858
$ python train.py -c conf/imagenet_resnet50.yaml

We ran 5 independent experiments on ResNet50.

  • Author's codes

    • 300epoch : 21.762, 21.614, 21.762, 21.644, 21.810
    • best : 21.56, 21.556, 21.666, 21.498, 21.648
  • Our Re-implementation

    • 300epoch : 21.53, 21.408, 21.55, 21.4, 21.73
    • best : 21.392, 21.328, 21.386, 21.256, 21.34

Reference

More Repositories

1

pytorch-gradual-warmup-lr

Gradually-Warmup Learning Rate Scheduler for PyTorch
Python
969
star
2

pytorch-randaugment

Unofficial PyTorch Reimplementation of RandAugment.
Python
627
star
3

unsupervised-data-augmentation

Unofficial PyTorch Implementation of Unsupervised Data Augmentation.
Python
147
star
4

remote-dataloader

PyTorch DataLoader processed in multiple remote computation machines for heavy data processings
Python
66
star
5

data-science-bowl-2018

End-to-end one-class instance segmentation based on U-Net architecture for Data Science Bowl 2018 in Kaggle
Python
57
star
6

tf-lcnn

Tensorflow implementation for 'LCNN: Lookup-based Convolutional Neural Network'. Predict Faster using Models Trained Fast with Multi-GPUs
Python
40
star
7

kaggle-human-protein-atlas-image-classification

Kaggle 2018 @ Human Protein Atlas Image Classification
Python
34
star
8

simulated-annealing-for-tsp

This code is to solve traveling salesman problem by using simulated annealing meta heuristic.
C++
28
star
9

deep-object-detection-models

Deep Learning으둜 ν•™μŠ΅λœ Object Detection Model 에 λŒ€ν•΄ μ •λ¦¬ν•œ Archive μž„.
19
star
10

pystopwatch2

Multi Stopwatch for Python
Python
12
star
11

ai-starthon-2019

Codes used on AI Starthon 2019. 1st place in total.
Python
8
star
12

chat-ui-dashboard

Svelte
8
star
13

wedding-invitation

CSS
4
star
14

evonorm

Pytorch Implementation of EvoNorm which reproduces paper's result
Python
4
star
15

HttpReverseProxy

HTTP reverse proxy designed to facilitate secure access to HTTP services located within an internal network
Python
3
star
16

tbreader

TensorBoard Log Parser
Python
2
star