Load and Preprocess Images

Learn to load images using the PIL package and perform transformations on images with torchvision.

Introduction to image preprocessing

Image processing is an important part of a computer vision project. This lesson will cover two important tools that help load and preprocess images.

First, we’ll review loading images with the Python Imaging Library (PIL). Second, we’ll review image transformations with the torchvision framework.

Python Imaging Library (PIL)

The Python Imaging Library (PIL) is a useful library for image processing because it comes with the following features:

  • It has extensive file format support.
  • It has efficient internal representation.
  • It has powerful image-processing functions.

It’s widely considered to be a must-have image-processing tool for Python developers.

Load an image

We can easily load an image via PIL using the open function:

Get hands-on with 1400+ tech skills courses.