CutMixImageDataGenerator (Keras)
Paper: CutMix: Regularization Strategy to Train Strong Classifiers with Localizable Features
Install
$ pip install cutmix-keras
How To Use
class CutMixImageDataGenerator():
def __init__(self, generator1, generator2, img_size, batch_size):
self.batch_index = 0
self.samples = generator1.samples
self.class_indices = generator1.class_indices
self.generator1 = generator1
self.generator2 = generator2
. . .
generator1,generator2need same generator appliedflowmethod
generator1,generator2needshuffle=True
Ifshuffle=False, This generator cutmix with same images.
So there would no augmentation
- Why are there two same generators? (
generator1,generator2)
--> To Solve Reference Problem
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
)
# CutMixImageDataGenerator
train_generator = CutMixImageDataGenerator(
generator1=train_generator1,
generator2=train_generator2,
img_size=IMG_SIZE,
batch_size=BATCH_SIZE,
)
Metadata
Release files for cutmix-keras 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| cutmix_keras-1.0.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / cutmix_keras-1.0.0-py3-none-any.whl
| Download URL | cutmix_keras-1.0.0-py3-none-any.whl |
|---|---|
| Size | 3.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ab31f7169394a94f13f1b22caec81f364b97000601d65f8d54b90d371e9b085d
|
|
BLAKE2b-256 checksum How to use checksums |
980f6678894736e65537ab42cd4f32dace6748cfd013a4bff2c8ac1f25a29d43
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.41.0 CPython/3.8.0
|
Security for cutmix-keras 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.