From 940f1a25fb4c69262c189aeaf9e79eebc0729094 Mon Sep 17 00:00:00 2001 From: FTC Engineering Date: Thu, 29 Oct 2020 20:41:01 -0400 Subject: [PATCH] Updated Using a TensorFlow Pretrained Model to Detect Everyday Objects (markdown) --- ...rained-Model-to-Detect-Everyday-Objects.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) 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