I am trying to setup a deep learning framework with a MaskRCNN model. I am using a LiDAR intensity raster image and a feature class of water body polygons to create the training data. When I run the arcgis.learn.prepare_data() tool, I get the following error message:
---------------------------------------------------------------------------AttributeError Traceback (most recent call last)<ipython-input-22-c485ff65baef> in <module> 2 # When running export training data for deep learning, make sure the meta data format is appropriate for the model 3 data_path = r'Q:/Data/CFlynn/DL_Breaklines/MaskRCNN/TrainingData4'----> 4 data = prepare_data(data_path, batch_size=2, imagery_type='ms')~\AppData\Local\ESRI\conda\envs\pyenvdeep\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) 630 kwargs['do_normalize'] = False 631 if transforms == None:--> 632 data = (src.transform(size=chip_size, tfm_y=True) 633 .databunch(**databunch_kwargs)) 634 else:~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\fastai\data_block.py in transform(self, tfms, **kwargs) 500 if not tfms: tfms=(None,None) 501 assert is_listy(tfms) and len(tfms) == 2, "Please pass a list of two lists of transforms (train and valid)."--> 502 self.train.transform(tfms[0], **kwargs) 503 self.valid.transform(tfms[1], **kwargs) 504 if self.test: self.test.transform(tfms[1], **kwargs)~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\fastai\data_block.py in transform(self, tfms, tfm_y, **kwargs) 718 def transform(self, tfms:TfmList, tfm_y:bool=None, **kwargs): 719 "Set the `tfms` and `tfm_y` value to be applied to the inputs and targets."--> 720 _check_kwargs(self.x, tfms, **kwargs) 721 if tfm_y is None: tfm_y = self.tfm_y 722 tfms_y = None if tfms is None else list(filter(lambda t: getattr(t, 'use_on_y', True), listify(tfms)))~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\fastai\data_block.py in _check_kwargs(ds, tfms, **kwargs) 588 if (tfms is None or len(tfms) == 0) and len(kwargs) == 0: return 589 if len(ds.items) >= 1:--> 590 x = ds[0] 591 try: x.apply_tfms(tfms, **kwargs) 592 except Exception as e:~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\fastai\data_block.py in __getitem__(self, idxs) 116 "returns a single item based if `idxs` is an integer or a new `ItemList` object if `idxs` is a range." 117 idxs = try_int(idxs)--> 118 if isinstance(idxs, Integral): return self.get(idxs) 119 else: return self.new(self.items[idxs], inner_df=index_row(self.inner_df, idxs)) 120 ~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\fastai\vision\data.py in get(self, i) 269 def get(self, i): 270 fn = super().get(i)--> 271 res = self.open(fn) 272 self.sizes[i] = res.size 273 return res ~\AppData\Local\ESRI\conda\envs\pyenvdeep\lib\site-packages\arcgis\learn\models\_maskrcnn_utils.py in open(self, fn) 139 x = gdal.Open(path).ReadAsArray() 140 if len(x.shape)==2:--> 141 x = x.unsqueeze(0) 142 x = torch.tensor(x.astype(np.float32)) 143 x = ArcGISMSImage(x)AttributeError: 'numpy.ndarray' object has no attribute 'unsqueeze'
I'd appreciate any comments or suggestions.
This issue can occur when Anaconda and ArcGIS Pro are installed on the same machine. This setup is not recommended because having two different Conda versions interfering with each other can lead to unexpected behavior. See the following documentation for more info:
https://developers.arcgis.com/python/guide/understanding-conda/
Fix:
- Uninstall Anaconda and set up a new deep learning python environment in ArcGIS Pro
https://pro.arcgis.com/en/pro-app/help/analysis/image-analyst/install-deep-learning-frameworks.htm