Skip To Content

Classify Objects Using Deep Learning (Image Analyst)

Mit der Image Analyst-Lizenz verfügbar.

Zusammenfassung

Runs a trained deep learning model on an input raster and an optional feature class to produce a feature class or table in which each input object has an assigned class label.

The trained deep learning model package consists of an Esri model definition JSON file (.emd). It contains the path to the Python raster function to be called to process each object and the path to the trained binary deep learning model file created from third-party training software such as PyTorch or Keras.

Verwendung

  • Sie müssen die dem jeweiligen Deep-Learning-Framework entsprechende Python-API (PyTorch oder Keras) in der Python-Umgebung von ArcGIS Pro installieren, da sonst beim Hinzufügen der Esri-Modelldefinitionsdatei zum Werkzeug ein Fehler auftritt. Die entsprechenden Framework-Informationen sollten von der Person bereitgestellt werden, die die Esri-Modelldefinitionsdatei erstellt hat.

    To set up your machine to use deep learning frameworks in ArcGIS Pro, see Install deep learning frameworks.

  • Mit diesem Werkzeug wird eine Deep-Learning-Python-API eines Drittanbieters (wie PyTorch oder Keras) aufgerufen und die angegebene Python-Raster-Funktion zum Verarbeiten der einzelnen Objekte verwendet.

  • Beispielanwendungsfälle für dieses Werkzeug finden Sie auf der Esri GitHub-Seite zu Python-Raster-FunktionenAnatomy of a Python raster function (Anatomie einer Python-Raster-Funktion).Sie können auch benutzerdefinierte Python-Module entwickeln, indem Sie den Beispielen und Anweisungen folgen.

  • The Esri model definition parameter value can be an Esri model definition JSON file (.emd), a JSON string, or a deep learning model package (.dlpk). A JSON string is useful when this tool is used on the server so you can paste the JSON string, rather than upload the .emd file. The .dlpk file must be stored locally.

  • See the sample below for the .emd file.

    {
        "Framework": "Keras",
        "ModelConfiguration":"KerasClassifier",
        "ModelFile":"C:\\DeepLearning\\Damage_Classification_Model_V7.h5",
        "ModelType":"ObjectClassification",
        "ImageHeight":256,
        "ImageWidth":256,
        "ExtractBands":[0,1,2],
        "CropSizeFixed": 1,
        "BlackenAroundFeature": 1,
        “ImageSpaceUsed”: “MAP_SPACE”, 
        "Classes": [
        {
           "Value": 0,
           "Name": "Damaged",
           "Color": [255, 0, 0]
        },
        {
           "Value": 1,
           "Name": "Undamaged",
           "Color": [76, 230, 0]
        }
        ]
    }
  • The CropSizeFixed property defines the crop mode of the raster tile around each object. A value of 1 means a fixed raster tile is used, defined by the ImageHeight and ImageWidth properties in the .emd file. The object is centered within the fixed tile size. A value of 0 means a variable tile size is used, in which the raster tile is cropped using the smallest bounding box around the object.

  • The BlackenAroundFeature property specifies whether the pixels that are outside each object will be masked. A value of 0 means the pixels outside of the object will not be masked. A value of 1 means the pixels outside of the object will be masked.

  • Weitere Informationen zu Deep Learning finden Sie unter Deep Learning in ArcGIS Pro.

Syntax

ClassifyObjectsUsingDeepLearning(in_raster, out_feature_class, in_model_definition, {in_features}, {class_label_field}, {processing_mode}, {model_arguments})
ParameterErklärungDatentyp
in_raster

The input raster dataset to classify. The input can be a single raster or multiple rasters in a mosaic dataset, an image service, or a folder of images.

Raster Dataset; Raster Layer; Mosaic Layer; Image Service; MapServer; Map Server Layer; Internet Tiled Layer; Folder
out_feature_class

The output feature class that will contain geometries surrounding the objects from the input feature class, as well as a field to store the classification label.

Feature Class
in_model_definition

The in_model_definition parameter value can be an Esri model definition JSON file (.emd), a JSON string, or a deep learning model package (.dlpk). A JSON string is useful when this tool is used on the server so you can paste the JSON string, rather than upload the .emd file. The .dlpk file must be stored locally.

It contains the path to the deep learning binary model file, the path to the Python raster function to be used, and other parameters such as preferred tile size or padding.

File; String
in_features
(optional)

The point, line, or polygon input feature class that identifies the location of each object to be classified and labelled. Each row in the input feature class represents a single object.

If no input feature class is specified, the tool assumes that each input image contains a single object to be classified. If the input image or images use a spatial reference, the output from the tool is a feature class, in which the extent of each image is used as the bounding geometry for each labelled feature class. If the input image or images are not spatially referenced, the output from the tool is a table containing the image ID values and the class labels for each image.

Feature Class; Feature Layer
class_label_field
(optional)

The name of the field that will contain the classification label in the output feature class.

If no field name is specified, a new field called ClassLabel will be generated in the output feature class.

String
processing_mode
(optional)

Specifies how all raster items in a mosaic dataset or an image service will be processed. This parameter is applied when the input raster is a mosaic dataset or an image service.

  • PROCESS_AS_MOSAICKED_IMAGEAll raster items in the mosaic dataset or image service will be mosaicked together and processed. This is the default.
  • PROCESS_ITEMS_SEPARATELYAll raster items in the mosaic dataset or image service will be processed as separate images.
String
model_arguments
[model_arguments,...]
(optional)

Die Funktionsargumente werden in der Python-Raster-Funktionsklasse definiert. Hier geben Sie zusätzliche Deep-Learning-Parameter und Argumente für Experimente und Verfeinerungen wie den Konfidenzschwellenwert zur Anpassung der Empfindlichkeit an. Die Namen der Argumente werden vom Werkzeug durch Lesen des Python-Moduls aufgefüllt.

Value Table

Codebeispiel

ClassifyObjectsUsingDeepLearning example 1 (Python window)

This example generates a new feature class with a label field to classify damaged and undamaged buildings in an image.

# Import system modules  
import arcpy  
from arcpy.ia import *  
 
# Check out the ArcGIS Image Analyst extension license 
arcpy.CheckOutExtension("ImageAnalyst") 
 
# Execute 
ClassifyObjectsUsingDeepLearning("C:/Data/Input_Image.tif", 
	"C:/Data/MyProject.gdb/Classified_Results", "C:/Data/BuildingDamageClassifier.emd", 
	"C:/Data/building_footprints.shp","Class_Label", 
	"PROCESS_AS_MOSAICKED_IMAGE", "padding 0;batch_size 4")
ClassifyObjectsUsingDeepLearning example 2 (stand-alone window)

This example generates a new feature class with a label field to classify damaged and undamaged buildings in an image.

# Import system modules  
import arcpy  
from arcpy.ia import *  
 
# Check out the ArcGIS Image Analyst extension license 
arcpy.CheckOutExtension("ImageAnalyst") 
 
# Define input parameters
in_raster = "C:/Classify_Objects/input_image.tif" 
out_feature_class = "C:/Classify_Objects/MyProject.gdb/classified_results" 
in_model_definition = "C:/Classify_Objects/BuildingDanmageClassifier.emd" 
in_features = "C:/Classify_Objects/building_footprints.shp" 
class_label_field = "Damaged_or_Undamaged"
model_arguments = "padding 0;batch_size 4"
process_all_raster_items = "PROCESS_AS_MOSAICKED_IMAGE"

# Execute 
ClassifyObjectsUsingDeepLearning(in_raster, out_feature_class, in_model_definition,
	in_features, class_label_field,  
	process_all_raster_items, model_arguments)

Lizenzinformationen

  • Basic: Erfordert Image Analyst
  • Standard: Erfordert Image Analyst
  • Advanced: Erfordert Image Analyst

Verwandte Themen