Moving from PIL to opencv in pytorch

I have been using pytorch for quite a while, but now, one of the projects I am working on, requires me to use opencv and no PIL :frowning:

Typically, I do this in pytorch:

        self.data_transforms = torchvision.transforms.Compose([
            torchvision.transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])

Id like to replicate the same with openCV with minimal effort (because the above snippet is present in quite a few of my dataloader classes).

What is the most efficient way to go about this?

This repository seems to have implemented (some) torchvision.transforms in OpenCV.