Hi,
I’m trying to run my TorchScript model in JAVA, but I get an error and my application crashes. I based on the code in the “HelloWorld” example application, which worked fine on my Android device.
code lines:
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Bitmap bitmap = null;
Module module = null;
try {
  // creating bitmap from packaged into app android asset 'image.jpg',
  Log.d("PytorchHelloWorld", "Loading input image");
  bitmap = BitmapFactory.decodeStream(getAssets().open("image2.jpg"));

  // loading serialized torchscript module from packaged into app android asset model.pt,
  // app/src/model/assets/model.pt
  Log.d("PytorchHelloWorld", "Loading pytorch model");
  module = Module.load(assetFilePath(this, "torchScript_model.pt"));
} catch (IOException e) {
  Log.e("PytorchHelloWorld", "Error reading assets", e);
  finish();
}

// showing image on UI
ImageView imageView = findViewById(R.id.image);
imageView.setImageBitmap(bitmap);

// preparing input tensor
Log.d("PytorchHelloWorld", "Preparing input tensor");
final Tensor inputTensor = TensorImageUtils.bitmapToFloat32Tensor(bitmap,
    TensorImageUtils.TORCHVISION_NORM_MEAN_RGB, TensorImageUtils.TORCHVISION_NORM_STD_RGB);

// running the model
Log.d("PytorchHelloWorld", "Running the model");
final Tensor outputTensor = module.forward(IValue.from(inputTensor)).toTensor();
TextView textView = findViewById(R.id.text);
textView.setText("ok");

}
logs
PytorchHelloWorld:	 Loading input image	
PytorchHelloWorld:	 Loading pytorch model	
AndroidRuntime:	 Shutting down VM	
AndroidRuntime:	 FATAL EXCEPTION: main	
AndroidRuntime:	 Process: org.pytorch.helloworld, PID: 8625	
AndroidRuntime:	 java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.helloworld/org.pytorch.helloworld.MainActivity}: com.facebook.jni.CppException: 	
AndroidRuntime:	 Arguments for call are not valid.	
AndroidRuntime:	 The following variants are available:	
AndroidRuntime:		
AndroidRuntime:	   aten::upsample_bilinear2d(Tensor self, int[2] output_size, bool align_corners) -> (Tensor):	
AndroidRuntime:	   Expected at most 3 arguments but found 5 positional arguments.	
AndroidRuntime:		
AndroidRuntime:	   aten::upsample_bilinear2d.out(Tensor self, int[2] output_size, bool align_corners, *, Tensor(a!) out) -> (Tensor(a!)):	
AndroidRuntime:	   Argument out not provided.
Can you please help me understand what’s the issue?