Preprocess images before feed into CNN

I am doing some experiments on MNIST. I want to preprocess images before feed them into CNN. My preprocess function is like

def preprocess(image):
    ...
    return processed_image

the result is a processed image with the same size as the original image.
I am trying to modify this code: pytorch examples mnist
I am wondering where I should add this preprocess function into the code. Thank you!

1 Like

Write a transforms. Tutorial.

2 Likes