This task generates object detection rasters using a JSON dataset containing COCO (Common Objects in Context)-formatted annotations. Each raster corresponds to labeled regions of interest defined in the COCO input annotations.
Example
e = ENVI()
RootCoco = 'C:\coco_data'
RootDl = 'C:\envi_dl_coco'
CocoTrainFile = RootCoco + Path_Sep() + 'train' + Path_Sep() + '_annotations.coco.json'
CocoValidFile = RootCoco + Path_Sep() + 'valid' + Path_Sep() + '_annotations.coco.json'
OutputTrainDir = RootDl + Path_Sep() + 'train'
OutputValidDir = RootDl + Path_Sep() + 'valid'
Task1 = ENVITask('BuildObjectDetectionRastersFromCOCO')
Task1.INPUT_COCO_JSON = CocoTrainFile
Task1.NUMBER_OF_RASTERS = 20
Task1.RANDOM_SELECTION = 1
Task1.RANDOM_SEED = 12345
Task1.ENHANCE_DISPLAY = 1
Task1.OUTPUT_RASTER_DIRECTORY = OutputTrainDir
Task1.Execute
Task2 = ENVITask('BuildObjectDetectionRastersFromCOCO')
Task2.INPUT_COCO_JSON = CocoValidFile
Task2.NUMBER_OF_RASTERS = 4
Task2.RANDOM_SELECTION = 1
Task2.RANDOM_SEED = 12345
Task2.ENHANCE_DISPLAY = 1
Task2.OUTPUT_RASTER_DIRECTORY = OutputValidDir
Task2.Execute
OutputModelUri = RootDl + Path_Sep() + 'model.envi.onnx'
TrainingFiles = File_Search(OutputTrainDir, '*.dat', count = nTraining)
if (nTraining eq 0) then message, 'No training rasters found in training folder'
TrainingRasters = objarr(nTraining)
foreach file, TrainingFiles, idx do TrainingRasters[idx] = ENVIDeepLearningObjectDetectionRaster(file)
ValidationFiles = File_Search(OutputValidDir, '*.dat', count = nValidation)
if (nValidation eq 0) then message, 'No validation rasters found in training folder'
ValidationRasters = objarr(nValidation)
foreach file, ValidationFiles, idx do ValidationRasters[idx] = ENVIDeepLearningObjectDetectionRaster(file)
Task3 = ENVITask('TrainDeepLearningObjectModel')
Task3.Model_Name = 'COCO Example'
Task3.Training_Rasters = TrainingRasters
Task3.Validation_Rasters = ValidationRasters
Task3.Epochs = 25
Task3.Patches_Per_Batch = 2
Task3.Output_Model_URI = OutputModelUri
Task3.Execute
Model = Task3.Output_Model
print, Model.Metrics, /IMPLIED_PRINT
Syntax
Result = ENVITask('BuildObjectDetectionRastersFromCOCO')
Input parameters (Set, Get): ENHANCE_DISPLAY, INPUT_COCO_JSON, NUMBER_OF_RASTERS, RANDOM_SEED, RANDOM_SELECTION, OUTPUT_RASTER_DIRECTORY, VISUAL_RGB
Output parameters (Get only): None
Properties marked as "Set" are those that you can set to specific values. You can also retrieve their current values any time. Properties marked as "Get" are those whose values you can retrieve but not set.
Input Parameters
ENHANCE_DISPLAY (optional)
Specify whether to apply an additional small stretch to the processed data to suppress noise and enhance feature visibility. The optional stretch is effective for improving visual clarity in imagery acquired from aerial platforms or sensors with higher noise profiles.
INPUT_COCO_JSON (required)
Specify the COCO-format annotation JSON file that defines the input raster images and their associated labeled regions of interest. Each entry in the file should follow the COCO specification, including image metadata and bounding box annotations for object detection.
NUMBER_OF_RASTERS (required)
Specify how many object detection rasters to generate from the COCO-annotated dataset. Previously generated rasters are skipped, allowing incremental creation of the full dataset over time.
RANDOM_SEED (optional)
Specify a seed value to ensure reproducible results. When RANDOM_SELECTION is enabled, using the same seed will consistently generate the same subset of rasters from the dataset.
RANDOM_SELECTION (optional)
Enable this parameter for random selection of rasters from the COCO dataset. If the NUMBER_OF_RASTERS equals the total number of available rasters, this parameters will be ignored.
OUTPUT_RASTER_DIRECTORY (required)
Specify the directory where generated object detection rasters from the COCO-annotated dataset will be saved.
VISUAL_RGB (optional)
Specify whether to encode the output raster as a three-band RGB composite (red, green, blue) for color image processing. This ensures consistent band selection from ENVI display types (such as RGB, CIR, and pan) and supports integration of diverse data sources (such as MSI, panchromatic, and VNIR) without band mismatch.
Methods
Execute
Parameter
ParameterNames
See ENVI Help for details on these ENVITask methods.
Properties
DESCRIPTION
DISPLAY_NAME
NAME
REVISION
TAGS
See the ENVITask topic in ENVI Help for details.
Version History
|
Deep Learning 4.0
|
Introduced |
See Also
BuildObjectDetectionRasterFromAnnotation Task, BuildObjectDetectionRasterFromROI Task, BuildObjectDetectionRasterFromVector Task, ENVIDeepLearningObjectDetectionRaster, TrainDeepLearningObjectDetectionModel Task