Coder Social home page Coder Social logo

Comments (4)

GyanendroKh avatar GyanendroKh commented on May 18, 2024 8

Well, I've been searching all over the place and finally I've figured it out. It's dead simple.
For some reason I thought that AssetFileDescriptor's getStartOffset is related to the actual tflite model but it's not. I think the getStartOffset gives the start point of the file in the application's asset. And for the tflite model the startOffset should be 0 because that's where the file start as it is only one file.
So, the code should be

File file = new File('path_to_model');
FileInputStream is = new FileInputStream(file);
    
return is.getChannel().map(FileChannel.MapMode.READ_ONLY, 0, file.length());

from android-tensorflow-lite-example.

liyoung1992 avatar liyoung1992 commented on May 18, 2024

I have the same problem

from android-tensorflow-lite-example.

susielau avatar susielau commented on May 18, 2024

Hi, I have a similar issue. Has anyone figured out how to solve it?

from android-tensorflow-lite-example.

mehedi-shafi avatar mehedi-shafi commented on May 18, 2024
File modelFile = new File(this.modelPath);
FileChannel channel = new FileInputStream(modelFile).getChannel();
interpreterInference = new Interpreter(channel.map(FileChannel.MapMode.READ_ONLY, 0, modelFile.length()), new Interpreter.Options());

This does load the model. Without any issue. But it arises a new problem which is

Caused by: java.lang.IllegalStateException: Internal error: Unexpected failure when preparing tensor allocations: tensorflow/lite/kernels/conv.cc:237 input->dims->size != 4 (1 != 4)Node number 0 (CONV_2D) failed to prepare.
    
        at org.tensorflow.lite.NativeInterpreterWrapper.allocateTensors(Native Method)

Well I guess that's because of the input tensor size (shape) I have to reshape the image I suppose.

from android-tensorflow-lite-example.

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.