Skip to content
This repository has been archived by the owner on Aug 28, 2024. It is now read-only.

Can I use the torchvision-ops library in Kotlin? #319

Open
HuChenHC opened this issue May 9, 2023 · 2 comments
Open

Can I use the torchvision-ops library in Kotlin? #319

HuChenHC opened this issue May 9, 2023 · 2 comments

Comments

@HuChenHC
Copy link

HuChenHC commented May 9, 2023

I'm using a model that requires torchvision.ops.nms. I can successfully load the model by running the D2G demo with replaced model file, but my app is using Kotlin, and without the below JAVA code block in MainActivity that loads the torchvision_ops library, I keep getting the error saying ops not found. Is there any way I can load torchvision-ops library in Kotlin?

Required code in JAVA, which I don't have in my Kotlin project :

static {
    if (!NativeLoader.isInitialized()) {
        NativeLoader.init(new SystemDelegate());
    }
    NativeLoader.loadLibrary("pytorch_jni");
    NativeLoader.loadLibrary("torchvision_ops");
}

My build.gradle includes:

implementation 'org.pytorch:pytorch_android_lite:1.10.0'
implementation 'org.pytorch:pytorch_android_torchvision_lite:1.10.0'
implementation 'org.pytorch:torchvision_ops:1.10.0'

The error I'm getting:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.testDetectionKotlin/com.example.testDetectionKotlin.MainActivity}: com.facebook.jni.CppException: Following ops cannot be found. Check fburl.com/missing_ops for the fix.{torchvision::roi_align, torchvision::nms, } ()

Is it possible to load the torchvision_ops library in Kotlin? Can anyone suggest the proper way to achieve that? If not, any suggestions on ways to use the model that needs torchvision_ops in Kotlin projects? Thank you!

@Jokestv2
Copy link

I am facing the same issue.

@NeighborhoodCoding
Copy link

Do you have some reference to use with yolov8?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants