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

FTC Engineering
2020-10-29 19:33:36 -04:00
parent 4276170a4d
commit 33367eb273
2 changed files with 31 additions and 7 deletions

@ -1,7 +0,0 @@
### Introduction
Teams have the option of using a custom TensorFlow object detection model to detect objects other than the current season's game elements. This tutorial demonstrates how use a pretrained model to look for and track everyday objects. This particular tutorial uses the OnBot Java programming tool, but teams can also use Android Studio or the Blocks programming tool to implement this example.
This tutorial assumes that you have already completed the steps in [a previous TensorFlow tutorial](Using-a-Custom-TensorFlow-Model-with-Java). If you have not yet completed the steps in the [previous TensorFlow tutorial](Using-a-Custom-TensorFlow-Model-with-Java), then please do so before continuing with this tutorial.
### Obtaining the Pretrained Model and Label Map
The custom inference model must be in the form of a TensorFlow Lite (.tflite) file. For this example, we will use the same Mobilenet object detection model that is used in Google's [example TensorFlow Object Detection Android app](https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android).

@ -0,0 +1,31 @@
### Introduction
Teams have the option of using a custom TensorFlow object detection model to detect objects other than the current season's game elements. This tutorial demonstrates how use a pretrained model to look for and track everyday objects. This particular tutorial uses the OnBot Java programming tool, but teams can also use Android Studio or the Blocks programming tool to implement this example. This tutorial covers an advanced topic and assumes that the user has good programming knowledge and is familiar with Android devices and computer technology.
This tutorial also assumes that you have already completed the steps in [a previous TensorFlow tutorial](Using-a-Custom-TensorFlow-Model-with-Java). If you have not yet completed the steps in the [previous TensorFlow tutorial](Using-a-Custom-TensorFlow-Model-with-Java), then please do so before continuing with this tutorial.
### Downloading the Pretrained Model and Label Map
The custom inference model must be in the form of a TensorFlow Lite (.tflite) file. For this example, we will use the same object detection model that is used in Google's [example TensorFlow Object Detection Android app](https://github.com/tensorflow/examples/tree/master/lite/examples/object_detection/android).
The model and its corresponding label map can be downloaded from [this link](http://storage.googleapis.com/download.tensorflow.org/models/tflite/coco_ssd_mobilenet_v1_1.0_quant_2018_06_29.zip).
The .zip archive contains a file called "detect.tflite". This TensorFlow Lite file is the inference model that TensorFlow will use to recognize the everyday objects. It is based on the mobilenet architecture, which was designed to provide low latency recognitions, while still maintaining reasonable recognition accuracy.
The .zip archive also contains a text file called "labelmap.txt". This text file contains a list of labels that correspond to the known objects in the "detect.tflite" model file.
Download the .zip archive to your laptop and uncompress its contents to a folder.
### Transferring the files to the Robot Controller
For this example, we want to transfer the .tflite and labelmap files to a directory on your robot controller.
If you are an advanced user and are familiar with using [adb](https://developer.android.com/studio/command-line/adb), then you can use adb to push the files to the directory "/sdcard/FIRST/tflitemodels" on your robot controller.
#### Transferring Using the Windows Explorer
If you do not know how to use the [Android Debug Bridge tool](https://developer.android.com/studio/command-line/adb), then you can use the File Explorer on a Windows laptop to copy and paste the files to this directory.
If you are using an Android phone as your robot controller, then connect the phone to your laptop using a USB cable. Swipe down from the top of the phone's screen to display the menu. Look for an item that indicates the USB mode that the phone is currently in. By default, most phones will be in a charging mode.
Tap on the mode item in the menu to bring up an activity that will allow to switch the phone into file transfer mode.
Select the File transfer mode and the phone should now appear as a browsable storage device in your computer's Windows Explorer.
If you are using a REV Robotics Control Hub, you can connect the Control Hub (that is powered on by a fully charged 12V battery) to your laptop using a USB Type C cable and the Control Hub will appear in your file browser. Use the Windows File Explorer to copy the two files (detect.tflite and labelmap.txt) and past them to the "FIRST/tflitemodels" subdirectory.