Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/devbruce/cutmiximagedatagenerator_for_keras
- Owner: devbruce
- License: mit
- Created: 2019-08-06T09:47:18.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T01:22:44.000Z (almost 5 years ago)
- Last Synced: 2024-11-09T05:46:47.968Z (10 days ago)
- Topics: augmentation, cutmix, generator, keras, regularizer
- Language: Python
- Homepage:
- Size: 8.79 KB
- Stars: 29
- Watchers: 3
- Forks: 12
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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 CutMixtrain_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