Now, let's write the classifier.
- 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); }
- Now, let's write the TensorFlow Lite ...