Digit classifier

Now, let's write the classifier.

  1. First, we will load the model file. This method reads the model from the assets folder and loads it into the memory:
/** Memory-map the model file in Assets. */ private MappedByteBuffer loadModelFile(Activity activity) throws I0Exception {     AssetFileDescriptor fileDescriptor = activity.getAssets().openFd(getModelPath());     FilelnputStream inputStream = new FileInputStream(fileDescriptor.getFileDescriptor());     FileChannel fileChannel = inputStream.getChannel();     long startOffset = fileDescriptor.getStartOffset();     long declaredLength = fileDescriptor.getDeclaredLength();         return fileChannel.map(FileChannel.MapMode.READ_ONLY, startOffset, declaredLength); }
  1. Now, let's write the TensorFlow Lite ...

Get Mobile Artificial Intelligence Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.