pytorch / android-demo-app

PyTorch android examples of usage in applications
1.48k stars 607 forks source link

ImageSegmentation model error #316

Open mhyeonsoo opened 1 year ago

mhyeonsoo commented 1 year ago

Hi,

I am trying to implement Instance Segmentation example on the android. At the time I first applied it, I met the error saying model verison.

So I used the code below to change the model version.

from torch.jit.mobile import (
    _backport_for_mobile,
    _get_model_bytecode_version,
)

MODEL_INPUT_FILE = "model_v7.ptl"
MODEL_OUTPUT_FILE = "model_v5.ptl"

print("model version", _get_model_bytecode_version(f_input=MODEL_INPUT_FILE))

_backport_for_mobile(f_input=MODEL_INPUT_FILE, f_output=MODEL_OUTPUT_FILE, to_version=5)

print("new model version", _get_model_bytecode_version(MODEL_OUTPUT_FILE))

After then, I could see two issues.

  1. converted model size has been doubled to ~168M --> ~336M
  2. when I tried to run, error message was shown
    java.lang.RuntimeException: Unable to start activity ComponentInfo{org.pytorch.demo.imagesegmentation/org.pytorch.imagesegmentation.MainActivity}: com.facebook.jni.CppException: isTuple()INTERNAL ASSERT FAILED at "../aten/src/ATen/core/ivalue_inl.h":1396, please report a bug to PyTorch. Expected Tuple but got String ()
    Exception raised from toTuple at ../aten/src/ATen/core/ivalue_inl.h:1396 (most recent call first):

Is there something that I missed?

Thanks,