Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public static MnistClassifier classifier(AssetManager assetManager, String modelPath) throws IOException {
ByteBuffer byteBuffer = loadModelFile(assetManager, modelPath);
Interpreter interpreter = new Interpreter(byteBuffer);
return new MnistClassifier(interpreter);
private static ByteBuffer loadModelFile(AssetManager assetManager, String modelPath) throws IOException {
AssetFileDescriptor fileDescriptor = assetManager.openFd(modelPath);
FileInputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel = inputStream.getChannel();
long startOffset = fileDescriptor.getStartOffset();
long declaredLength = fileDescriptor.getDeclaredLength();
return, startOffset, declaredLength);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.