Torchvision transforms in c++

I have a pytorch model. During training I use torchvision transforms to transform the images. I now want to use the model as a torchscript and call through c++. Ideally, I’d like to be able to use the same torchvision transforms in c++ (without re-writing myself in c++), apply them to the images and then pass through the model. Is this possible? If the torchvision transforms can’t be called from c++, what’s the suggested alternative approach?

If you are using torchvision.transforms, which can be applied to tensors, you could add them to the forward method of your model and script them.
On the other hand, if you are using image transformation, which are applied to PIL.Images, you won’t be able to use them directly in C++ (at least I’m not aware of a way to use PIL in C++) and could use e.g. OpenCV, which is available in Python and C++ for the preprocessing instead.