Classify Pixels Using Deep Learning Python Automation

274
1
09-23-2021 07:53 AM
Labels (2)
TimothyMcKinney
New Contributor III

I am looking for some help automating the geoprocessing tool "Classify Pixels Using Deep Learning". I am using the per-trained license plate blurring model found here: https://www.arcgis.com/home/item.html?id=2ae3cf1af09847a48d65c04b9da6a84f

 

My question: Using python can the tool take in images directly and export images or do all images have to be imported into a GDB, processed with an export into a GDB and then exported as an image file?

 

In my testing of the provided python script found on the below page, I cannot get a solution that does not require import and export through a GDB.

https://pro.arcgis.com/en/pro-app/latest/tool-reference/image-analyst/classify-pixels-using-deep-lea...

 

I am looking to setup a script that will take an input folder of images and run the license plate and face blurring models on them and export these images to another folder. Ideally, the processed images would be the same size/quality and have the same name as the originals. Any help with an efficient way of doing this would be appreciated.

 

0 Kudos
1 Reply
TimothyMcKinney
New Contributor III

To automate I have a loop setup and the first file runs but then there is always an unexpected error for the second file.

 

 

# Import system modules
import arcpy
import os
from arcpy.ia import *
from arcpy import env
import time

arcpy.CheckOutExtension("ImageAnalyst")

####File list...

for x in file_list:
    out_classified_raster = arcpy.ia.ClassifyPixelsUsingDeepLearning(raw_path + "\\" + x, model, "score_threshold 0.8", "PROCESS_ITEMS_SEPARATELY", None)
    out_classified_raster.save(export_path + "\\" + os.path.splitext(x)[0] + ".tif")

 

 

 
---------------------------------------------------------------------------
ExecuteError                              Traceback (most recent call last)
In  [78]:
Line 2:     out_classified_raster = arcpy.ia.ClassifyPixelsUsingDeepLearning(raw_path + "\\" + x, model, "score_threshold 0.8", "PROCESS_ITEMS_SEPARATELY", None)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ia\Functions.py, in ClassifyPixelsUsingDeepLearning:
Line 1041:  out_classified_folder)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\sa\Utils.py, in swapper:
Line 53:    result = wrapper(*args, **kwargs)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\ia\Functions.py, in Wrapper:
Line 1034:  out_classified_folder)

File C:\Program Files\ArcGIS\Pro\Resources\ArcPy\arcpy\geoprocessing\_base.py, in <lambda>:
Line 512:   return lambda *args: val(*gp_fixargs(args, True))

ExecuteError: ERROR 999999: Something unexpected caused the tool to fail. Contact Esri Technical Support (http://esriurl.com/support) to Report a Bug, and refer to the error help for potential solutions or workarounds.
Unable to read pixels from the python raster function.
Function Read Error [Raster Function Template]
Unable to read pixels from the python raster function.
Python raster function's .updatePixels() method returned nothing.
Unable to read pixels from the python raster function.
Function Read Error [Raster Function Template]
Unable to read pixels from the python raster function.
Python raster function's .updatePixels() method returned nothing.
Unable to read pixels from the python raster function.
Function Read Error [Raster Function Template]
Unable to read pixels from the python raster function.
Python raster function's .updatePixels() method returned nothing.
Failed to execute (ClassifyPixelsUsingDeepLearning).

 

0 Kudos