Torchvision.ops.nms on Android Mobile

I was able to successfully use the operations by loading them with facebooks native loading. Here’s some code to load torchvision_ops:

import com.facebook.soloader.nativeloader.NativeLoader;
import com.facebook.soloader.nativeloader.SystemDelegate;

With this in main:

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