-
-
Save akakitani/e08809fe35ce74cad3dce3cf98aa155c to your computer and use it in GitHub Desktop.
custom_model_inference.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// create a model interpreter for local model (bundled with app) | |
FirebaseModelOptions modelOptions = new FirebaseModelOptions.Builder() | |
.setLocalModelName(“model_name”) | |
.build(); | |
modelInterpreter = FirebaseModelInterpreter.getInstance(modelOptions); | |
// specify input output details for the model | |
// SqueezeNet architecture uses 227 x 227 image as input | |
modelInputOutputOptions = new FirebaseModelInputOutputOptions.Builder() | |
.setInputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, 227, 227, 3}) | |
.setOutputFormat(0, FirebaseModelDataType.FLOAT32, new int[]{1, numLabels}) | |
.build(); | |
// create input data | |
FirebaseModelInputs input = new FirebaseModelInputs.Builder().add(imgDataArray).build(); // imgDataArray is a float[][][][] array of (1, 227, 227, 3) | |
// run inference | |
modelInterpreter.run(input, modelInputOutputOptions); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment