Skip to content

Instantly share code, notes, and snippets.

@shubham0204
Created May 1, 2019 04:03
Show Gist options
  • Save shubham0204/bcf7dec139c82713cf74d48eb453864f to your computer and use it in GitHub Desktop.
Save shubham0204/bcf7dec139c82713cf74d48eb453864f to your computer and use it in GitHub Desktop.
@Throws(IOException::class)
private fun loadModelFile(): MappedByteBuffer {
val MODEL_ASSETS_PATH = "model.tflite"
val assetFileDescriptor = assets.openFd(MODEL_ASSETS_PATH)
val fileInputStream = FileInputStream(assetFileDescriptor.getFileDescriptor())
val fileChannel = fileInputStream.getChannel()
val startoffset = assetFileDescriptor.getStartOffset()
val declaredLength = assetFileDescriptor.getDeclaredLength()
return fileChannel.map(FileChannel.MapMode.READ_ONLY, startoffset, declaredLength)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment