Custom Image manipulation

Hi I am participating in a Kaggle competition:

so what i want help with are following:

  • creating a copy of all images and inverting them and then adding then in the dataset

now i know a function (PIL.ImageOps.invert(img)) that can invert a single image but how do i go about doing it for all the images and can i do it using GPU that will increase the speed

also once they are inverted how do i combine them with original to create the dataset

You could just write a loop or use multithreading to create an inverted copy of all of the images in a data pre-processing step. Look at using threadpool + map as that should be fastest. Doing it on the GPU will not make it faster unless you do it randomly per batch in your dataloader. You can add a custom Transform to your Datablock/Dataloader to do this. Depending on where you add it it would be as simple as 255 - x or 1 - x depending on if your add it before or after your image range is converted from 0-255 to 0-1.

2 Likes

thanks for your ideas, i figured it will be fastest and will save precious GPU time if i do it separately and upload as a new dataset on kaggle.