Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/devbruce/cutmiximagedatagenerator_for_keras

Keras implementation of CutMix regularizer
https://github.com/devbruce/cutmiximagedatagenerator_for_keras

augmentation cutmix generator keras regularizer

Last synced: about 2 hours ago
JSON representation

Keras implementation of CutMix regularizer

Awesome Lists containing this project

README

        

# CutMixImageDataGenerator (Keras)

![GitHub release (latest by date)](https://img.shields.io/github/v/release/DevBruce/CutMixImageDataGenerator_For_Keras)

> Paper: [CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features](https://arxiv.org/abs/1905.04899)

## Citation

```
@misc{yun2019cutmix,
title={CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features},
author={Sangdoo Yun and Dongyoon Han and Seong Joon Oh and Sanghyuk Chun and Junsuk Choe and Youngjoon Yoo},
year={2019},
eprint={1905.04899},
archivePrefix={arXiv},
primaryClass={cs.CV}
}
```


## Install

```bash
$ pip install cutmix-keras
```


## Using Example

```python
# (some codes) ...
from cutmix_keras import CutMixImageDataGenerator # Import CutMix

train_datagen = ImageDataGenerator(
rescale=1./255,
)

train_generator1 = train_datagen.flow_from_dataframe(
dataframe=X_train,
directory=IMG_DIR,
target_size=(IMG_SIZE, IMG_SIZE),
x_col='X_Column',
y_col='Y_Column',
color_mode='rgb',
class_mode='categorical',
batch_size=BATCH_SIZE,
shuffle=True, # Required
)

train_generator2 = train_datagen.flow_from_dataframe(
dataframe=X_train,
directory=IMG_DIR,
target_size=(IMG_SIZE, IMG_SIZE),
x_col='X_Column',
y_col='Y_Column',
color_mode='rgb',
class_mode='categorical',
batch_size=BATCH_SIZE,
shuffle=True, # Required
)

# !! Define CutMixImageDataGenerator !!
train_generator = CutMixImageDataGenerator(
generator1=train_generator1,
generator2=train_generator2,
img_size=IMG_SIZE,
batch_size=BATCH_SIZE,
)

# (some codes) ...
history = model.fit_generator(
generator=train_generator,
steps_per_epoch=train_generator.get_steps_per_epoch(),
# (some parameters) ...
)
```


### Example of Kaggle Kernel

Link: [[KaKR\_2019\_3rd] CutMix, Ensemble (Keras)](https://www.kaggle.com/devbruce/kakr-2019-3rd-cutmix-ensemble-keras#Generator)


- `generator1`, `generator2` need same generator applied `flow` method


- `generator1`, `generator2` need `shuffle=True`
If `shuffle=False`, This generator cutmix with same images.
So there would no augmentation


- Why are there two same generators? (`generator1`, `generator2`)
\-\-\> To Solve Reference Problem