The right way to Course of 10k Photos in Seconds | by Florian Trautweiler | Jan, 2025

Environment friendly picture operations with multiprocessing in Python

Dataset for Picture Processing

Handbook, repetitive duties. Egh. One of many issues I hate essentially the most, particularly if I do know they are often automated. Think about you’ll want to edit a bunch of photos with the identical cropping and resizing operation. For a few photos you would possibly simply open a picture editor and do it by hand. However what about doing the similar operation for a 1000’s or tens of 1000’s of photos? Let’s see how we will automate such a picture processing job with Python and OpenCV, in addition to how we will optimize this knowledge processing pipeline to run effectively on a sizeable dataset.

For this put up, I created a toy instance the place I extracted 10,000 frames from a random video of a seaside I recorded, the place the purpose is to crop the picture to a sq. side ratio across the middle after which resize the picture to a set measurement of 224×224.

This roughly resembles a part of a pre-processing step that is perhaps required for a dataset when coaching a machine studying mannequin.

Illustration of Crop and Resize Operation