Skip to content

Instantly share code, notes, and snippets.

@DanishAmjad12
Created October 16, 2022 14:54
Show Gist options
  • Save DanishAmjad12/f0ef5bc4208498719f5bd301e030a818 to your computer and use it in GitHub Desktop.
Save DanishAmjad12/f0ef5bc4208498719f5bd301e030a818 to your computer and use it in GitHub Desktop.
private MappedByteBuffer loadFile() throws IOException {
AssetFileDescriptor fileDescriptor=this.getAssets().openFd("degree.tflite");
FileInputStream inputStream=new FileInputStream(fileDescriptor.getFileDescriptor());
FileChannel fileChannel=inputStream.getChannel();
long startOffset=fileDescriptor.getStartOffset();
long declareLength=fileDescriptor.getDeclaredLength();
return fileChannel.map(FileChannel.MapMode.READ_ONLY,startOffset,declareLength);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment