PyTorch is a nice deep learning library, rich features, easy to learn, lots of pre-trained models, describe model by PyTorch is a pleasure, the only problem I am facing is the model trained by PyTorch is very hard to create a stand alone app.
Do community have a plan to make PyTorch easier to deploy? Like cooperate with opencv dnn?In my humble opinion, If opencv dnn can load the models trained by PyTorch, PyTorch will overcome biggest weak point and become more attractive.
@smth Thanks for your efforts on the project. As for me, this project is not as interesting as the opencv dnn module, with dnn module, I can forward my data into the models with one and only api, I do not need to deal with different languages on different platforms. But with ONNX, although the models are deployable, I still need to write x codes for x platforms.
The beauty of opencv dnn is, no matter what kind of os you are running, you can forward your models by the same c++ api, while caffe2 adopt solution similar to tensorflow, generate different api for different platforms(please correct me if I am wrong). I think this solution is not as portable as opencv dnn, why not just provide a set of c++ api which could compile on windows, mac, linux, android and ios like opencv dnn did? If any users favor java or another languages, there are many tools could generate the api from c++.
Maybe I misunderstand your question, but Caffe2 actually has the same C++ api to invoke inference (caffe2::Predictor) and is built from the same C++ source code on iOS, Android, Linux, Mac, Windows, etc. So it seems to be similar availability level to opencv dnn (please correct me if I’m wrong). You can check out the example android app to get the idea: https://github.com/bwasti/AICamera/blob/master/app/src/main/cpp/native-lib.cpp We’re definitely working on better tutorials show-casing how e2e flow using onnx.
It’s a good point that wrappers for other languages like Java are not there by default, but we’re open contributions!
In reality, if you’re talking about mobile deployment, there still would be differences in how you load your models (e.g. assets for mobile app) and potentially different optimizations you might want to do on your model for the optimal perf.
Another thing which might be interesting is to implement ONNX -> OpenCV DNN importer. It’s a bit lower priority on our list, but if you want to give it a try - please do, onnx is designed to be an open spec independent from the framework