Including LibTorchvision on Android
See original GitHub issueArea Select
react-native-pytorch-core (core package)
Description
Hello, thanks for your contributions.
I encountered a error on react native android to loading custom ptl model. I think this error can solve if i can include Libtorchvision from relavated issue on this: https://github.com/facebookresearch/playtorch/issues/64
How can i include it in my android application?
Please provide me any leads. Thank you.
Error:
{"message": "Following ops cannot be found. Please check if the operator library is included in the build. If built with selected ops, check if these ops are in the list. If you are a Meta employee, please see fburl.com/missing_ops for a fix. Or post it in https://discuss.pytorch.org/torchvision::nms () Exception raised from initialize_operators at /data/users/atalman/pytorch/torch/csrc/jit/mobile/function.cpp:89 (most recent call first): (no backtrace available)"}
Issue Analytics
- State:
- Created a year ago
- Comments:6 (2 by maintainers)
Hi @nh9k, that’s correct. The nms (non-maximum suppression) op is part of the Torchvision ops. The
react-native-pytorch-core
doesn’t include the Torchvision ops, but they can be added to a project, if needed.I created a repo for the D2Go model, which also requires Torchvision ops to run inference. I created a single commit for the changes that add Torchvision ops to Android and iOS. Have a look at this commit in the
raedle/D2GoExample
repo!Note: for iOS it uses the
LibTorchvision-DONOTUSE
CocoaPod because the Torchvision ops0.13.0
that are compatible with PyTorch1.12
have not been released officially yet. They are coming soon, and in the meantime you can use theLibTorchvision-DONOTUSE
, which are functionally equivalent to the upcoming release!Hope that helps, and please report back if you are successful! Any feedback to the PlayTorch is helpful for us to learn 😃
Thank you!
@nh9k, from the logcat logs it looks like that the shared object libraries aren’t packaged correctly.
But generally, there are two parts that are important to add
torchvision_ops
to your app. See how this is done in the PlayTorch app:torchvision_ops
to the app’s build.gradle (make sure the versions fortorchvision_ops
andpytorch_jni_lite
are compatible)torchvision_ops
shared object library after loading thepytorch_jni_lite
shared object library (see MainApplication.java)