diff --git a/Using-a-TensorFlow-Pretrained-Model-to-Detect-Everyday-Objects.md b/Using-a-TensorFlow-Pretrained-Model-to-Detect-Everyday-Objects.md index 0b44696..7f06572 100644 --- a/Using-a-TensorFlow-Pretrained-Model-to-Detect-Everyday-Objects.md +++ b/Using-a-TensorFlow-Pretrained-Model-to-Detect-Everyday-Objects.md @@ -187,4 +187,23 @@ Call the readLabels() method to read the label map and generate the labels list. // first. initVuforia(); initTfod(); +``` + +#### Load Model from a File +Modify the initTfod() method to load the inference model from a file (rather than as an app asset): + +``` + /** + * Initialize the TensorFlow Object Detection engine. + */ + private void initTfod() { + int tfodMonitorViewId = hardwareMap.appContext.getResources().getIdentifier( + "tfodMonitorViewId", "id", hardwareMap.appContext.getPackageName()); + TFObjectDetector.Parameters tfodParameters = new TFObjectDetector.Parameters(tfodMonitorViewId); + tfodParameters.minResultConfidence = 0.6; + tfod = ClassFactory.getInstance().createTFObjectDetector(tfodParameters, vuforia); + if(labels != null) { + tfod.loadModelFromFile(TFOD_MODEL_FILE, labels); + } + } ``` \ No newline at end of file