Object Detection Tutorial
Use the TensorFlow Object Classification tool to classify a raster using a trained object detection model. Run this tool as many times as needed to classify multiple rasters. The output is a shapefile of bounding boxes for each class.
You can also write a script to classify a raster using the TensorFlowObjectClassification task.
Follow these steps:
- Open the TensorFlow Object Classification dialog using one of the following options:
- In the ENVI Toolbox, select Deep Learning > Object Detection > TensorFlow Object Classification. The TensorFlow Object Classification dialog appears.
- In the Deep Learning Guide Map, click the following button sequence: Object Detection > Object Classification. The TensorFlow Object Classification dialog appears. An advantage of this option is that if you access the Deep Learning Labeling Tool through the Guide Map and use it to create label rasters and train a model, the Guide Map knows about the trained model and automatically populates the Input Model field (Step 3 below) with that model file.
- In the Input Raster field, select a raster to classify. It must contain at least as many bands as the raster that was used to train the model.
- In the Input Trained Model field, select a trained TensorFlow model file in HDF5 format (.h5).
- For the Confidence Threshold, use the slider bar or up/down arrow buttons to specify a threshold value between 0 and 1.0. Bounding boxes with a confidence score less than this value will be discarded before applying the Intersection Over Union Threshold value. The default value is 0.2. Decreasing this value generally results in more classification bounding boxes throughout the scene. Increasing it results in fewer classification bounding boxes.
- For the Intersection Over Union Threshold, use the slider bar or up/down arrow buttons to specify a value from 0 to 1.0 indicating the Non-Maximum Suppression Intersection over Union (NMS IOU) value. This is a TensorFlow object detection parameter that reduces detection clustering by pruning bounding boxes that have high IOU with previously selected boxes. The default value is 0.5. Increasing this value results in more overlapping bounding boxes around features. Decreasing the value results in fewer overlapping bounding boxes.
- In the Output Classification Vector field, select a path and filename for the output shapefile (.shp). The shapefile contains bounding boxes for each class.
- Enable the Display result check box to display the output in the view when processing is complete.
-
To reuse these task settings in future ENVI sessions, save them to a file. Click the down arrow next to the OK button and select Save Parameter Values, then specify the location and filename to save to. Note that some parameter types, such as rasters, vectors, and ROIs, will not be saved with the file. To apply the saved task settings, click the down arrow and select Restore Parameter Values, then select the file where you previously stored your settings.
-
To run the process in the background, click the down arrow and select Run Task in the Background. If an ENVI Server has been set up on the network, the Run Task on remote ENVI Server name is also available. The ENVI Server Job Console will show the progress of the job and will provide a link to display the result when processing is complete. See the ENVI Servers topic in ENVI Help for more information.
- Click OK.
Evaluate the Results
Display the output shapefile over the raster that you classified. If the resulting bounding boxes are not satisfactory, you can run the Postprocess Classification Vector tool to try different Confidence Threshold and Intersection Over Union Threshold values without having to run the classification tool again.
To help you determine a more suitable Confidence Threshold, you can view "Confidence" values for individual bounding boxes. To do this, right-click on the shapefile layer in the Layer Manager and select View/Edit Attributes. The Attribute Viewer lists the "Confidence" values for all of the shapefile records (i.e., bounding boxes); for example:
When the shapefile is displayed in the ENVI view, you can draw a box around multiple bounding boxes that you want to evaluate further. From the Attribute Viewer menu bar, select Options > Sort by Current Selection. The corresponding records are highlighted in the Vector Properties dialog so that you can see their confidence values:
In this example with false positives and significant overlap between bounding boxes, the "Confidence" values range from 0.437 to 0.964. This suggests that you should increase the Confidence Threshold to a higher value like 0.8.
See Also
Train Object Detection Models, Post-process Classification Vectors, Object Detection, TensorFlow Pixel Classification