def keras_augmented_image_generator(images,
                                    onehots,
                                    batch_size,
                                    datagen):
    """
    Create a generator from with augmentation via an ImageDataGenerator
    The generator can then be used for training in model.fit_generator

    The ImageDataGenerator should be configured with the desired augmentations.
    Note: when brightness is used, rescale=1./255 must also be used
    (assuming a desired output range of [0,1] as currently brightness augmentation internally rescales to [0,255]

    :param images: Images to augment
    :param onehots: Onehot encoding of target class
    :param batch_size: Batch size for training
    :param datagen: The ImageDataGenerator with augmentation options configured
    :return:
    """
    return datagen.flow(images,
                        onehots,
                        batch_size=batch_size,
                        shuffle=True)