Train Deep Learning Model - U-Net Error

770
2
08-07-2022 04:37 PM
Labels (2)
Relssuak
New Contributor

Hello,

I am currently working on a classification of high reslution images.

For this i wanted to create a deep learning approach of a pixel based image classification. I am using ArcGIS Pro 2.9.

The labeling of my data was done by importing a shapefile with classes end exported the trainingdata with classified tiles (Size 256, Stride 128).

By trying to train the model with the U-Net Model type with these training data, i get the following error message:

Traceback (most recent call last):
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\fastai\vision\learner.py", line 119, in unet_learner
try: size = data.train_ds[0][0].size
AttributeError: 'tuple' object has no attribute 'size'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Toolboxes\Image Analyst Tools.tbx\TrainDeepLearningModel.tool\tool.script.execute.py", line 301, in execute
training_model_object = training_model(data_bunch, **kwargs)
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\learn\models\_unet.py", line 223, in __init__
split_on=backbone_split,
File "C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\fastai\vision\learner.py", line 120, in unet_learner
except: size = next(iter(data.train_dl))[0].shape[-2:]
AttributeError: 'list' object has no attribute 'shape'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Toolboxes\Image Analyst Tools.tbx\TrainDeepLearningModel.tool\tool.script.execute.py", line 378, in <module>
execute()
File "c:\program files\arcgis\pro\Resources\ArcToolbox\Toolboxes\Image Analyst Tools.tbx\TrainDeepLearningModel.tool\tool.script.execute.py", line 373, in execute
del training_model_object
UnboundLocalError: local variable 'training_model_object' referenced before assignment

"

As i am not that much into coding (but looking forward to it) and i dont find any other solutions on the web, i hope i can find a solution for this problem here

 

Thank you in advance!

0 Kudos
2 Replies
Relssuak
New Contributor

I have managed to solve the problem - there was accidently set another "Additional Input Raster". Removing it from the "Export Training Data" Tool solved it.

But the results of the classification with U Net Pixel classification i not satisfactory. Within my created Classified Raster, there are only a few pixel of only one class classified which are mostly located within the are of my traing samples.

I attached a image of the Raster Attribut Table and a example of some of the classified pixels.

EsriUnet.PNGEsriUnet1.PNG

Anybody knows what i did wrong? I used the standard parameters of each geoprocessing tool.

 

Thanks!

0 Kudos
PavanYadav
Esri Contributor

Hi @Relssuak 
I would check the quality of the model and more importantly how it's performing on both training and validation datasets. You can review it in the model_metrics.html. Here are some general suggestions to improve the model:
1. Add more samples

2. Add variety of random samples that represent your entire area of interest. 

3. Make sure each classes have enough number of samples

4. When training try to use a large number for epochs e.g. 500, if possible. The tool might not see model improving let's say after 100 epochs so it should stop here (for this situation you can use the 'Stop when model stops improving)

 

Cheers!

Pavan

0 Kudos