Object detection with ArcGIS API job failed error

972
19
06-27-2021 01:02 PM
TaehyunYoon1
New Contributor

Purpose: I want to detect and count objects from downloaded map images.

Map data: I use a high-resolution google earth map image with ArcGIS pro.

Model: I used a single-shot detector. I trained the model with a labeled image that I did through ArcGIS pro.

References:

https://developers.arcgis.com/python/sample-notebooks/detecting-swimming-pools-using-satellite-image...

https://developers.arcgis.com/python/guide/object-detection/

Problems and Question (4 questions)

  • When I save my model, the '.zip' file does not appear. The Models folder has (ModelCharacteristics folder, ArcGISobjectDetector python file, model_metrics chrome HTML Document, .dlpk, emd, and .pth files). When I followed the references above, they used the '.zip' file for 'gis.content.add' function.

TaehyunYoon1_0-1624823848411.png

TaehyunYoon1_1-1624823860960.png

TaehyunYoon1_2-1624823881994.png

 

  • Instead of the “.zip” file, I used a “.dlpk” file for “gis.content.add” function.

 

TaehyunYoon1_3-1624823904393.png

 

TaehyunYoon1_4-1624823914606.png

  • I shared the ".tiff" image file to ArcGIS online content from ArcGIS pro web-share 

 

TaehyunYoon1_7-1624824105758.png

 

TaehyunYoon1_6-1624823962095.png

 

  • I followed references, but it did not work. It notices me only “job failed.” I could not figure out what is the problem. 

 

0 Kudos
19 Replies
Tim_McGinnes
Occasional Contributor III

It's not possible to run the deep learning models in ArcGIS Online. You basically have 3 options:

  • ArcGIS Enterprise with ArcGIS Image Server
  • ArcGIS Pro with the Image Analyst extension
  • ArcGIS Python API (dependent on model type)

The sample notebook you are following has the following in the prerequisites section:

This sample demonstrates how to do export training data and model inference using ArcGIS Image Server. Alternatively, they can be done using ArcGIS Pro as well.

If you don't have either Image Server or Pro + Image Analyst, there are prediction (detection) functions in the ArcGIS Python API for some models. SingleShotDetector does have one:

https://developers.arcgis.com/python/api-reference/arcgis.learn.toc.html#arcgis.learn.SingleShotDete... 

ssd.predict(image_path, threshold=0.5, nms_overlap=0.1, return_scores=False, visualize=False, resize=False)

It returns a List of xmin, ymin, width, height of predicted bounding boxes on the given image.

0 Kudos
TaehyunYoon1
New Contributor

I appreciate your prompt response Tim!!


I am working on ArcGIS Python API. Although I don’t know what the Image Analyst extension is, I also use the ArcGIS pro I purchased.
Although I was supposed to use ArcGIS Pro for this project, I faced a GPU prerequisite problem. For this reason, I am working on my school’s computing resource center server with ArcGIS Python API.
I labeled rectangular boxes on the training dataset through ArcGIS Pro and trained a deep learning model on ArcGIS Python API.
I do not fully understand how to use “ssd.predict” command. Do I have to use it after I train my model?
Please let me know where I can get the sample code for using “ssd.predict”?
Actually, I am a Ph.D. student in a different field. I only want to get data through object detection of satellite image data. If you have any better suggestions for this purpose, It will great help for me.

0 Kudos
Tim_McGinnes
Occasional Contributor III

Yes after training you can run the predict function straight away:

from arcgis.learn import SingleShotDetector, prepare_data
data_path = r'<path>\ImageChips' 
data = prepare_data(data_path)
ssd = SingleShotDetector(data)
ssd.lr_find()
ssd.fit(5, lr=1e-2)
ssd.show_results()
ssd.plot_losses()
ssd.average_precision_score()
ssd.save(r'<path>\<model>',save_inference_file=True)
listresults=ssd.predict(image_path, threshold=0.5, nms_overlap=0.1, return_scores=True, visualize=False, resize=False)

 To load the saved model from disk and predict you should be able to do:

from arcgis.learn import SingleShotDetector
ssd = SingleShotDetector.from_model(r'<path_to_model_emd_file>')
listresults=ssd.predict(image_path, threshold=0.5, nms_overlap=0.1, return_scores=True, visualize=False, resize=False)

The threshold parameter is the important one - the example above will only return detection over 50% confidence.

TaehyunYoon1
New Contributor

Thank you Tim,

Is it possible to visualize as .tiff image?

Also, can I count detected objects? 

 

0 Kudos
Tim_McGinnes
Occasional Contributor III

It is a list, so the length of the list should be how many objects were detected - do for the above code:

numobjects=len(listresults)

Unfortunately to see the bounding boxes you would have to take the xmin, ymin, width and height and create your own polygons. One of the advantages of using the ArcGIS Pro tools is that they do all that work for you.

0 Kudos
TaehyunYoon1
New Contributor

TaehyunYoon1_0-1625278017344.png

How did they do this visualization? this is from the reference notebooks above.

0 Kudos
Tim_McGinnes
Occasional Contributor III

They were using the ArcGIS Image Server to do the detect_objects function, which outputs polygons directly. Unfortunately the predict function can't do that.

0 Kudos
TaehyunYoon1
New Contributor

Hello Tim,

 

When I use ssd.predict with visualize=True, can I make the result picture bigger with better resolution?

0 Kudos
TaehyunYoon1
New Contributor

 

I faced a different problem that has not been a problem so far.
I am working on esri_learn deep learning dependencies.
The CUDA error below has not appeared before, even last night.
I re-installed dependencies, but it did not work.
Do you have any idea what the problem is?

 

TaehyunYoon1_0-1625258132577.png

 

0 Kudos