CutMixImageDataGenerator For Keras Save Abandoned

Keras implementation of CutMix regularizer

Project README

CutMixImageDataGenerator (Keras)

GitHub release (latest by date)

Paper: CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features

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

$ pip install cutmix-keras

Using Example

# (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)


  • 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
Open Source Agenda is not affiliated with "CutMixImageDataGenerator For Keras" Project. README Source: devbruce/CutMixImageDataGenerator_For_Keras
Stars
30
Open Issues
3
Last Commit
4 years ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating