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

NoneType return loadModuleFromAsset(getAssets(), "d2go.pt");

Open pankajkumar9797 opened this issue 4 years ago • 11 comments

 Caused by: com.facebook.jni.CppException: 
Unknown type name 'NoneType':
Serialized   File "code/__torch__/torch/nn/intrinsic/quantized/modules/conv_relu.py", line 24
    return _0
  def __setstate__(self: __torch__.torch.nn.intrinsic.quantized.modules.conv_relu.ConvReLU2d,
    state: Tuple[int, int, Tuple[int, int], Tuple[int, int], Tuple[int, int], Tuple[int, int], bool, Tuple[int, int], int, str, Tensor, Optional[Tensor], float, int, bool]) -> NoneType:
                                                                                                                                                                                ~~~~~~~~ <--- HERE
    self.in_channels = (state)[0]
    self.out_channels = (state)[1]

pankajkumar9797 avatar Jun 29 '21 07:06 pankajkumar9797

I am facing the same issue

Parth38 avatar Jul 08 '21 11:07 Parth38

cc @jeffxtang

Parth38 avatar Jul 09 '21 19:07 Parth38

Did you create d2go.pt using the script in the repo, or use the model file directly in the repo?

jeffxtang avatar Jul 09 '21 20:07 jeffxtang

I am creating d2go.pt in Google colab

Parth38 avatar Jul 09 '21 20:07 Parth38

I am training custom model and for conversion I am referring create_d2go.py

Parth38 avatar Jul 09 '21 20:07 Parth38

Did you use PyTorch 1.9 and torchvision 0.10.0 to create your model? Then the build.gradle needs to be updated with 1.9.0 like this and use the lite version api like this.

Or you can install PyTorch 1.8 and torchvision 0.9 to work with the current Android code.

jeffxtang avatar Jul 09 '21 20:07 jeffxtang

I am facing the same issue.

I followed @jeffxtang advice, but I get this error on android:

start activity ComponentInfo{org.pytorch.demo.objectdetection/org.pytorch.demo.objectdetection.MainActivity}: com.facebook.jni.CppException: PytorchStreamReader failed locating file bytecode.pkl: file not found ()

from the line :

mModule = LiteModuleLoader.load(MainActivity.assetFilePath(getApplicationContext(), "d2go.pt"));

I guess d2go is only supported for Pytorch 1.8 : (If I am not mistaken) [https://pytorch.org/mobile/android/] pytorch d2go version

Now I am trying to run the notebook again from colab with Pytorch installed 1.8. But that doesn't seem to work :\ Import errors from torch text.. ImportError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZN2at6detail10noopDeleteEPv

Any leads ?

The goal is to try the balloon toy set on D2go so I could later twist it to my Custom dataset.

MayarLotfy avatar Jul 12 '21 13:07 MayarLotfy

D2Go for PyTorch 1.9 works, but an updated script is required to create the model - please checkout the PyTorch 1.9 updated D2Go iOS demo app, steps 1-3 of here for now. Will update this D2Go Android demo app to 1.9 soon.

jeffxtang avatar Jul 12 '21 16:07 jeffxtang

@MayarLotfy I am trying this in colab and it has started to train !pip install --pre torch==1.8.0 torchvision==0.9.0 torchtext==0.9.1 -f https://download.pytorch.org/whl/nightly/cu101/torch_nightly.html -U Will update whether the generated .pt file is working

Parth38 avatar Jul 13 '21 13:07 Parth38

The app is crashing when I press detect. I think we have to wait for the updated app

Parth38 avatar Jul 15 '21 17:07 Parth38

@jeffxtang I am getting this error Process: org.pytorch.demo.objectdetection, PID: 9752 com.facebook.jni.CppException: Method 'forward' is not defined. Exception raised from get_method at ../../../../src/main/cpp/libtorch_include/x86/torch/csrc/jit/api/object.h:96 (most recent call first): (no backtrace available) at org.pytorch.NativePeer.forward(Native Method) at org.pytorch.Module.forward(Module.java:49) at org.pytorch.demo.objectdetection.MainActivity.run(MainActivity.java:241) at java.lang.Thread.run(Thread.java:923) I/Process: Sending signal. PID: 9752 SIG: 9

Parth38 avatar Jul 20 '21 16:07 Parth38