I've exported Classfied_Tile formatted image chips from ArcGIS Pro to train a Unet Classifier. However, when setting up 'prepare_data' function I get an UnboundLocalError. I'm running this in Jupyter Lab
Input:
data = prepare_data(data_path, {1:'Ocean', 2:'Sand', 3:'Mud', 4:'Pond', 5:'Red Pond', 6:'Foam', 7:'Tundra', 8:'Bare', 9:'Mud' }, batch_size=16, dataset_type = 'Classified_Tiles')
Output:
---------------------------------------------------------------------------UnboundLocalError Traceback (most recent call last)<ipython-input-9-ab7c0384d6f5> in <module>() 5 # however, this notebook leaves out the fact that you need to directly infer that to the script with 'dataset_type' 6 ----> 7 data = prepare_data(data_path, {1:'Ocean', 2:'Sand', 3:'Mud', 4:'Pond', 5:'Red Pond', 6:'Foam', 7:'Tundra', 8:'Bare', 9:'Mud' }, batch_size=16, dataset_type = 'Classified_Tiles')~\AppData\Local\ESRI\conda\envs\palm-detection\lib\site-packages\arcgis\learn\_data.py in prepare_data(path, class_mapping, chip_size, val_split_pct, batch_size, transforms, collate_fn, seed, dataset_type, resize_to, **kwargs) 463 elif dataset_type == 'Classified_Tiles': 464 --> 465 def get_y_func(x, ext=right): 466 return x.parents[1] / 'labels' / (x.stem + '.{}'.format(ext)) 467 UnboundLocalError: local variable 'right' referenced before assignment
I should mention, I don't get this error when using PASCAL rectangles for SSO training. Looks like it has something to do with classified tiles format.
Can someone help me get around this?
Thanks.
Solved! Go to Solution.
I've updated ArcGIS Pro to 2.5.0 and it is now exporting the esri_accumulated_stats files I need to make this work.
I also had had to reclone the arcgis python3 environment and install the latest deep learning libraries that are recommended by esri.
Anyone from ESRI want to chime in on this??!!
Looking through the _data.py library, I think I know what's going on. prepare_data is expecting there to be a "esri_accumulated_stats.json" to be in the export directory that Pro creates when you export your training data. However, this file is never created in the process. In _data.py, it searchers for this .json, doesn't find it and then jumps to a line (around 465) where "right" is called in a function, but "right" is declared outside of the scope. Attached to this post is a screen shot of the data directory that gets created during "Export Training Data for Deep Learning".
I've updated Pro to 2.4.3 and it still does this.
You ESRI model definition file is missing, what is the version of your ArcGIS pro. Can you try again using ArcGIS pro 2.4 or above ?
I've updated ArcGIS Pro to 2.5.0 and it is now exporting the esri_accumulated_stats files I need to make this work.
I also had had to reclone the arcgis python3 environment and install the latest deep learning libraries that are recommended by esri.