Updated Using a TensorFlow Pretrained Model to Detect Everyday Objects (markdown)

FTC Engineering
2020-10-30 07:33:34 -04:00
parent f9ff535d48
commit ce4824903d

@ -52,7 +52,7 @@ Use Windows Explorer to browse the internal shared storage of your Android devic
Now the files are where we want them to be for this example.
### Modifying a Sample Op Mode
Use the OnBot Java editor to create a new op mode that is called "TFODEverydayObjects" and that is based on the "ConceptTensorFlowObjectDetection" sample op mode. Note that a copy of the full op mode that was used for this example (except for the Vuforia key) is included at the end of this tutorial.
Use the OnBot Java editor to create a new op mode that is called "TFODEverydayObjects" and select "ConceptTensorFlowObjectDetection" as the sample op mode that will serve as the template for your new op mode. Note that a copy of the full op mode that was used for this example (except for the Vuforia key) is included at the end of this tutorial.
#### Modify the Name and Enable the Op Mode
Modify the annotations to change the name to avoid a "collision" with any other op modes on your robot controller that are based on the same sample op mode. Also comment at the @Disabled annotation to enable this op mode.
@ -140,7 +140,7 @@ Create a method called readLabels() that will be used to read the label map file
```
Important note: The readLabels() method actually skips the first line of the "labelmap.txt" file. If you review Google's [example TensorFlow Object Detection Android app](https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android) carefully you will notice that the app actually extracts the label map as metadata from the .tflite file. If you build and run the app, you will see that when the the app extracts the labels from the .tflite file's metadata, the first label is "person". In order to ensure that your labels are in sync with the known objects of the sample .tflite model, the readLabels() method skips the first line of the label map file and starts with the second label ("person"). I suspect that the first line of the label map file might be reserved for future use (or it might be an error in the file).
You will also need to define the getStringArray() method which the readLabels() method uses to convert the ArrayList to a String array.
You will also need to define the getStringArray() method which the readLabels() method uses to convert an ArrayList to a String array.
```
// Function to convert ArrayList<String> to String[]