android-demo-app icon indicating copy to clipboard operation
android-demo-app copied to clipboard

Pytorch lite version problem with error in android app

Open Jagan3534 opened this issue 2 years ago • 1 comments

for our custom .ptl model we got error in this Ivalue

for this line code we we got this output

Tensor inputTensor = TensorImageUtils.bitmapToFloat32Tensor(bitmap,TensorImageUtils.TORCHVISION_NORM_MEAN_RGB,TensorImageUtils.TORCHVISION_NORM_STD_RGB);

the output of this line

Tensor([1, 3, 224, 224], dtype=torch.float32)

from next line onwards we are facing error

Tensor outputTensor = module.forward(IValue.from(inputTensor)).toTensor();
float[] scores = outputTensor.getDataAsFloatArray();

and

IValue inputs = IValue.from(outputTensor);
IValue[] outputs = module.forward(inputs).toTuple();

i tried in both ways

i got the error like this

java.lang.IllegalStateException: Expected IValue type Tuple, actual type TensorList
at org.pytorch.IValue.preconditionType(IValue.java:332)
at org.pytorch.IValue.toTuple(IValue.java:313)

if anyone solve this error please help us

Jagan3534 avatar Nov 05 '22 09:11 Jagan3534