Image Processing Layers

Learn about various preprocessing layers available in Keras and implement commonly used image-processing layers.

The Keras preprocessing layers API allows us to build data processing pipelines. The layers provided by this API preprocess data during neural network training. These layers become part of a Keras DL model. Keras preprocessing layers make the DL model accept raw unprocessed data/images as input and preprocess the data during the model training process. Keras provides preprocessing layers for numerous tasks that include:

  • Image preprocessing: Rescale, resize, and center-crop images.

  • Image data augmentation: Randomly translate, rotate, crop, flip, zoom in/out, and change the image contrast.

  • Feature preprocessing:

    • Numerical feature preprocessing: Normalization and discretization.

    • Categorical feature preprocessing: Feature encoding and hashing.

  • Text preprocessing: String encoding.

Let’s learn about some of the commonly used image preprocessing layers in Keras.

The Rescaling layer

Usually, we store images on a storage device using 8-bit color graphics. Each image pixel uses 8 bits; therefore, the range of values for 8-bit image pixels is [0, 255] integer values. To process images in the TF framework, we have to convert them to tensors.

Get hands-on with 1200+ tech skills courses.