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

Thomas

2 Likes

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

6 Likes

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++?

Hi @erict. It has been a while since I worked on torchvision and I have some incomplete PRs there. Unfortunately I don’t have the time to work on Transforms or other stuff right now.

Hi @ShahriarSS,

ok i will try to do something by myself based on your work. If i get something useful i will share here. Have you some hints on which could be the best way? for example i’m planning to use opencv to do some transform. Do you think could be a good starting point?

@erict I suggest you open an issue in torchvision and discuss the design there and then start. This way you will know how to start and it’ll be approved by torchvision. Feel free to mention me so I can help.

1 Like