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.
Problems and Question (4 questions)
It's not possible to run the deep learning models in ArcGIS Online. You basically have 3 options:
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:
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.
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.
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.
It is a list, so the length of the list should be how many objects were detected - do for the above code:
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.
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?