About torchvision for C++ frontend

The C++ frontend of PyTorch seems not completed to me. If we want to train a model in Python and deploy that model in C++, we have to do hard about code porting. And I think most likely is the part of data preprocessing which could be implemented by torchvision in Python, but it’s missing in C++.

The torchvision package in Python mainly have 2 modules:

  • torchvision.models
  • torchvision.transforms

For C++ to use these,
The torchvision.models I think may be easily ported by JIT. The painful part is the torchvision.transform. If I used the code from the module in training phase, does it mean that I have to implement the same transforms in C++ now? Is the torchvision for C++ in schedule?

Indeed, torchvision C++ support isn’t matching Python support.
However, @ShahriarSS is doing some good work on it, so the gap is getting smaller.

My guess is that most people use OpenCV to do transforms or do them manually. (Personally, I incorporated things like “normalizing” into the traced/scripted model last time I did this.)

Best regards


1 Like

Hi Thomas. The progress in TorchVision’s C++ side: Models have been written and I will start working on Transforms soon.


Hi sshahriarSS, is there a github repo that you working on?

The models exist in TorchVision repository which can be installed using cmake.

Great, saw it already on the master branch :smiley:

Hi @ShahriarSS,

thanks for your work. Any update for Transforms in C++?