GithubHelp home page GithubHelp logo

Comments (9)

kaiquesacchi avatar kaiquesacchi commented on May 19, 2024 2

Yesterday we found out about this config and solved the problem in that exact way (the first option you suggested)!
Anyway, thank you so much for taking your time to help us. Your solution works. :) @ganaware

I have had a similer problem.
The cause of the problem is that Mono is the default scripting backend for a new unity project for Android.
Unfortunately, Mono can run only for the ARMv7 architecture.

So my solution is that:

  1. Project Settings > Player > Android > Other Settings > Configuration

    • Select IL2CPP for Scripting Backend
    • Uncheck ARMv7 and check ARM64 for Target Architectures
  2. Or, build my own TFLite library for ARMv7

    • libnnapi_delegate.so, libtensorflowlite_c.so, libtensorflowlite_gpu_delegate.so
    • They worked fine for me.

from tf-lite-unity-sample.

ganaware avatar ganaware commented on May 19, 2024 1

I have had a similer problem.
The cause of the problem is that Mono is the default scripting backend for a new unity project for Android.
Unfortunately, Mono can run only for the ARMv7 architecture.

So my solution is that:

  1. Project Settings > Player > Android > Other Settings > Configuration
    • Select IL2CPP for Scripting Backend
    • Uncheck ARMv7 and check ARM64 for Target Architectures
  2. Or, build my own TFLite library for ARMv7
    • libnnapi_delegate.so, libtensorflowlite_c.so, libtensorflowlite_gpu_delegate.so
    • They worked fine for me.

from tf-lite-unity-sample.

FrankSpalteholz avatar FrankSpalteholz commented on May 19, 2024

Hi Roberto, i was facing similar issues on iOS with my iPad. In my case it had to do with the orientation (landscape, portrait etc). So most front-camera-sensors in smart-phones and tablets are rotated by 90 degrees and although Unity is able to compensate for that the inputTexture (WebCamTexture) is not taking account for that. So i had to flip the xAxes of the keypoints (1f-keypoint) and also flip uv's and normals of the face-mesh, but this only works on landscape-mode. You could also rotate your rendercam and mirror the canvas. In the end i was using OpenCV to adjust the textures how needed because it was the cleanest solution for my purposes. Hope this helps.

from tf-lite-unity-sample.

asus4 avatar asus4 commented on May 19, 2024

Thanks for sharing it @FrankSpalteholz

@Roberto7766 Do you get any errors on logcat?

from tf-lite-unity-sample.

Roberto7766 avatar Roberto7766 commented on May 19, 2024

Thanks @FrankSpalteholz and @asus4.
Using logcat I found out that the issue is with the neural network. If I comment the NN part the camera works well.
Here the logcat result:

2020-10-30 08:09:02.815 20668-20687/? E/Unity: DllNotFoundException: libtensorflowlite_c
        at (wrapper managed-to-native) TensorFlowLite.InterpreterOptions.TfLiteInterpreterOptionsCreate()
      at TensorFlowLite.InterpreterOptions..ctor () [0x00006] in <9d167a8ec82e4b91b0e30378348ced48>:0
      at TensorFlowLite.BaseImagePredictor`1[T]..ctor (System.String modelPath, System.Boolean useGPU) [0x00006] in :0
      at TensorFlowLite.SSD..ctor (System.String modelPath) [0x00035] in :0
      at SsdSample.Start () [0x00011] in :0   

  (Filename: Line: 0)
2020-10-30 08:09:07.986 20668-20687/? E/Unity: NullReferenceException: Object reference not set to an instance of an object
      at SsdSample.Update () [0x00000] in :0 

Maybe I did something wrong setting up the project?

from tf-lite-unity-sample.

asus4 avatar asus4 commented on May 19, 2024

It seems like failing to load the TensorFlow Lite library. Please make sure that the CPU isn't 32bit. But I've confirmed some cases that 64bit Android fails as well.

from tf-lite-unity-sample.

Roberto7766 avatar Roberto7766 commented on May 19, 2024

It is 64bit. What can be done to move forward? Thks.

from tf-lite-unity-sample.

asus4 avatar asus4 commented on May 19, 2024

The only thing I could see from the logcat is that the library is failing to load. We need to investigate the cause of the problem.

from tf-lite-unity-sample.

kaiquesacchi avatar kaiquesacchi commented on May 19, 2024

I've cloned the repo and got it to work on Android, Windows and Linux. I've even added my own Image Classification model, created a new scene, loaded it and got it to work as well.

When I tried creating a new Unity project and then adding the package (using the Package Manager and selecting the package file given in the Packages folder of your repo), I only got it to work with Windows and Linux. For some reason, when using it on Android, it breaks after trying to create instances of InterpreterOptions and Interpreter.

Are you aware of any additional steps that should be performed in order to add the package to a new project?

from tf-lite-unity-sample.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.