Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
custom_model_inference.java
// 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
You can’t perform that action at this time.