isears / tf_clahe

CLAHE implemented in python TF ops
MIT License
24 stars 3 forks source link

Not working on TPU notebooks #1

Open isears opened 3 years ago

isears commented 3 years ago

There are reports of this library not working when running on a TPU.

innat commented 1 year ago

I used it inside a model and no issue when running on TPU (kaggle). Works with GPU, TPU.

# Preprocessing
data_preprocessing = keras.Sequential(
    [
        Resizing(
            *INP_SIZE, 
            interpolation="bilinear"
        )
    ], 
    name='PreprocessingLayers'
)

# Augmentation
data_augmentations = keras.Sequential(
    [
        RandomCrop(*INP_SIZE),
        RandomFlip("horizontal"),
        RandomZoom(0.1, fill_mode='nearest'),
        RandomRotation(0.1, fill_mode='nearest'),
        CLAHE(
            tile_grid_size=(4, 4), clip_limit=3.0
        )
    ],
    name='AugmentationLayers'
)
model = keras.Sequential(
        [
            keras.layers.InputLayer(input_shape=INP_SIZE+(3,)),
            data_preprocessing,
            data_augmentations,
            applications.EfficientNetB0(include_top=False, pooling='avg'),
            ...
        ]
    )

One thing though, if I place CLAHE right after the Resize method, then there's a problem.