POST
|
I am following the automatic road extraction using deep learning sample notebook. My code is mostly the same (instead of pointing to data path in arcgis online I am pointing to folder that holds training data). I have created my own training data that I am using. When I run: data = prepare_data(datapath, chip_size=512, batch_size=10) I get the error: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_arcgis_model.py:366: UserWarning: Cuda is not available
warnings.warn("Cuda is not available") But I still get results for: data.show_batch(alpha=1) Then when I run: model = MultiTaskRoadExtractor(data, mtl_model="hourglass") I get the following AttributeError: ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\PIL\Image.py in open(fp, mode)
2846 try:
-> 2847 fp.seek(0)
2848 except (AttributeError, io.UnsupportedOperation):
AttributeError: 'numpy.ndarray' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-5-f5e8368fe40d> in <module>
----> 1 model = MultiTaskRoadExtractor(data, mtl_model="hourglass")
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_multi_task_road_extractor.py in __init__(self, data, backbone, pretrained_path, *args, **kwargs)
176
177
--> 178 self._orient_data=self._get_road_orient_data(data,**kwargs)
179 if len(data.classes) > 2:
180 raise Exception(
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_multi_task_road_extractor.py in _get_road_orient_data(self, data, **kwargs)
378 dataset_type=self._data.dataset_type, resize_to=self._data.resize_to, **kwargs)
379 road_orient_obj = RoadOrientation(self._data,road_data_obj, **kwargs)
--> 380 orient_data = road_orient_obj.get_databunch(data,**kwargs)
381 return orient_data
382
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in get_databunch(self, orig_data, **kwargs)
262
263
--> 264 data.chip_size = data.train_ds[0][0].shape[-1]
265 data.c = len(self.class_mapping) if self.class_mapping else 2
266
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in __getitem__(self, index)
344
345 def __getitem__(self, index):
--> 346 image, label = self._getRoadData(index)
347
348 seed = np.random.randint(2147483647) # make a seed with numpy generator
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in _getRoadData(self, index)
407 #
408 #image = PILImage.fromarray(np.asarray(ArcGISMSImage.open_gdal(image_dict["image"]))).astype(np.uint8)
--> 409 label = self._get_mask(np.asarray(PILImage.open(image_dict["label"])))
410
411 return image, PILImage.fromarray(label).convert("L")
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\PIL\Image.py in open(fp, mode)
2847 fp.seek(0)
2848 except (AttributeError, io.UnsupportedOperation):
-> 2849 fp = io.BytesIO(fp.read())
2850 exclusive_fp = True
2851
AttributeError: 'numpy.ndarray' object has no attribute 'read' I am running ArcGIS Pro 2.8.0, I have image analyst and spatial analyst turned on and have installed the ArcGIS Pro 2.8 deep learning libraries from github. Photos:
... View more
08-26-2021
10:11 AM
|
0
|
0
|
581
|
POST
|
I am following the automatic road extraction using deep learning sample notebook. My code is exactly the same. I have created my own training data that I am using. When I run: data = prepare_data(datapath, chip_size=512, batch_size=10) I get the error: C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_arcgis_model.py:366: UserWarning: Cuda is not available
warnings.warn("Cuda is not available") But I still get results for: data.show_batch(alpha=1) Then when I run: model = MultiTaskRoadExtractor(data, mtl_model="hourglass") I get the following AttributeError: ---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\PIL\Image.py in open(fp, mode)
2846 try:
-> 2847 fp.seek(0)
2848 except (AttributeError, io.UnsupportedOperation):
AttributeError: 'numpy.ndarray' object has no attribute 'seek'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-5-f5e8368fe40d> in <module>
----> 1 model = MultiTaskRoadExtractor(data, mtl_model="hourglass")
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_multi_task_road_extractor.py in __init__(self, data, backbone, pretrained_path, *args, **kwargs)
176
177
--> 178 self._orient_data=self._get_road_orient_data(data,**kwargs)
179 if len(data.classes) > 2:
180 raise Exception(
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\models\_multi_task_road_extractor.py in _get_road_orient_data(self, data, **kwargs)
378 dataset_type=self._data.dataset_type, resize_to=self._data.resize_to, **kwargs)
379 road_orient_obj = RoadOrientation(self._data,road_data_obj, **kwargs)
--> 380 orient_data = road_orient_obj.get_databunch(data,**kwargs)
381 return orient_data
382
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in get_databunch(self, orig_data, **kwargs)
262
263
--> 264 data.chip_size = data.train_ds[0][0].shape[-1]
265 data.c = len(self.class_mapping) if self.class_mapping else 2
266
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in __getitem__(self, index)
344
345 def __getitem__(self, index):
--> 346 image, label = self._getRoadData(index)
347
348 seed = np.random.randint(2147483647) # make a seed with numpy generator
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\arcgis\learn\_data_utils\_road_orient_data.py in _getRoadData(self, index)
407 #
408 #image = PILImage.fromarray(np.asarray(ArcGISMSImage.open_gdal(image_dict["image"]))).astype(np.uint8)
--> 409 label = self._get_mask(np.asarray(PILImage.open(image_dict["label"])))
410
411 return image, PILImage.fromarray(label).convert("L")
C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\lib\site-packages\PIL\Image.py in open(fp, mode)
2847 fp.seek(0)
2848 except (AttributeError, io.UnsupportedOperation):
-> 2849 fp = io.BytesIO(fp.read())
2850 exclusive_fp = True
2851
AttributeError: 'numpy.ndarray' object has no attribute 'read' I am running ArcGIS Pro 2.8.0, I have image analyst and spatial analyst turned on and have installed the ArcGIS Pro 2.8 deep learning libraries from github. Photos:
... View more
08-26-2021
10:08 AM
|
0
|
0
|
556
|
POST
|
I am building a Task Workflow to automate deployment of Crowdsource Polling. I have a task for creating a feature layer from a spreadsheet that sets up a relationship class between the feature layer and related commenting table. Once this is finished I need to symbolize the layer based on a field in the comment layer. I have created a layer file to accomplish this need by symbolizing based on layer file. I have got this to work before packaging the project but need it to work from within a packaged project. When I use the Package Project tool I have saved a the layer file (.lyrx) using the "additonal files" input: This adds the .lyrx into the commondata folder of the package. My issue is that when I get the path for the .lyrx and plug it into my code I am getting a ValueError. When I do this before packaging the project I do not get a ValueError. I have also tried running the code from the package after I use the extract package tool and get the same error. Here is my code: p = os.path.dirname(arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase)
aprx = arcpy.mp.ArcGISProject("CURRENT")
m = aprx.listMaps("Map")[0]
default_gdb = arcpy.mp.ArcGISProject("CURRENT").defaultGeodatabase
rec_sites = os.path.join(default_gdb, "RecSitesXY")
# local layer file path before packaging project
#lf = arcpy.mp.LayerFile(os.path.join(p, "FeeToolRecSiteSymbols.lyrx"))
# pro package layer file
# layer filepath after packaging project
lf = os.path.join(os.path.dirname(p), 'commondata', 'pro-recfeetool-deployment-task-workflow', 'FeeToolRecSiteSymbols.lyrx')
# add coment layer and symbolize using layer file
m.addDataFromPath(rec_sites)
# Using insert layer instead of arcpy.ApplySymbologyFromLayer_management because
# there is a known bug that this will not work from within a script
m.insertLayer(m.listLayers()[0],lf)
# clean up
m.removeLayer(m.listLayers()[1])
aprx.save()
I have also tried to search for the layer file this way and have tried using the output path with the same error
The value error happens at this point in the code: m.insertLayer(m.listLayers()[0],lf) Any help would be much appreciated.
... View more
05-01-2020
01:14 PM
|
0
|
0
|
396
|
POST
|
I think I can use the delete_from_definition (json_dict) method listed here arcgis.features.managers module — arcgis 1.0.1 documentation. I just need to figure out how to use it properly...
... View more
03-07-2017
09:49 AM
|
1
|
0
|
2032
|
IDEA
|
I think that when an item is created from an existing feature layer: # Create a new empty comment layer from the already existing base comment layer layer_properties={ 'title':'Test_Comment_Layer', 'description':'This is a comment layer that is being used for testing purposes only', 'tags':'Test, Python, Comment Layer', 'type':'Feature Service', 'url':'URL HERE' } base_comment_layer = gis.content.add(item_properties=layer_properties, data="URL HERE", folder=pf_name) that we should be able to choose which layers we would like to add from that Hosted Feature Layer (or Feature Layer Collection): 1) Create feature layer from existing layer: 2) Specify layers to include: The above code will create a Hosted Feature Layer with all layers included. Correct me if I'm wrong... but I would assume that this could be specified in the item_properties described in the content manager section ArcGIS API for Python guide: arcgis.gis module — arcgis 1.0.1 documentation It seems simple to delete features of a layer, or to delete the feature layer collection itself, but to delete a layer that is a part of a feature layer collection (or specify which layers to include) is not an easy task.
... View more
03-07-2017
09:18 AM
|
3
|
0
|
1231
|
IDEA
|
I think that when an item is created from an existing feature layer: # Create a new empty comment layer from the already existing base comment layer layer_properties={ 'title':'Test_Comment_Layer', 'description':'This is a comment layer that is being used for testing purposes only', 'tags':'Test, Python, Comment Layer', 'type':'Feature Service', 'url':'URL HERE' } base_comment_layer = gis.content.add(item_properties=layer_properties, data="URL HERE", folder=pf_name) that we should be able to choose which layers we would like to add from that Hosted Feature Layer (or Feature Layer Collection): 1) Create feature layer from existing layer: 2) Specify layers to include: The above code will create a Hosted Feature Layer with all layers included. Correct me if I'm wrong... but I would assume that this could be specified in the item_properties described in the content manager section ArcGIS API for Python guide: arcgis.gis module — arcgis 1.0.1 documentation It seems simple to delete features of a layer, or to delete the feature layer collection itself, but to delete a layer that is a part of a feature layer collection (or specify which layers to include) is not an easy task.
... View more
03-07-2017
09:18 AM
|
3
|
0
|
1382
|
POST
|
I guess what I mean by feature service is that it's a feature layer collection.
... View more
03-06-2017
12:59 PM
|
0
|
0
|
2032
|
POST
|
This makes sense for deleting the feature service completely, but as for deleting its layers or tables it doesn't make sense to me. I can access the object (see comment below this one) but if I use the delete method on the object I get AttributeError: 'FeatureLayer' object has no attribute 'delete' If I ask for the object's id I get 1, which is local to the feature service itself.
... View more
03-06-2017
12:44 PM
|
0
|
1
|
2032
|
POST
|
Reporting back: from arcgis.features import FeatureLayerCollection fs_url = 'URL HERE' comments = FeatureLayerCollection(fs_url, gis=gis) layers = comments.layers tables = comments.tables for layer in layers: print(layer) for table in tables: print(table) Output will return each layer and table object. Tried del layers[1] but object does not support item deletion.
... View more
03-06-2017
12:34 PM
|
0
|
0
|
2032
|
POST
|
So I created a new feature service (Feature Layer Collection) into a folder. It is an empty feature service with layers and table relationships. Each layer has a geometry type. I only want points. How can I delete the line and polygon layers and tables using the ArcGIS API for python? I will continue to read documentation and if I figure it out I will post back here.
... View more
03-06-2017
12:17 PM
|
0
|
6
|
3315
|
POST
|
I solved my issue. For those interested: layer_properties={ 'title':'Test_Comment_Layer', 'description':'This is a comment layer that is being used for testing purposes only', 'tags':'TPCM, Test, Python, Comment Layer', 'type':'Feature Service', 'url':'URL to Feature Service' } gis.content.add(item_properties=layer_properties, data="URL to Feature Service", folder='test_NF')
... View more
03-06-2017
11:00 AM
|
4
|
1
|
2304
|
POST
|
I have a feature layer hosted in my organization that I want to turn into a new feature layer in my content, similar to this functionality: I was messing around with some code: base_comment_layer = gis.content.get('# acutal item ID goes here') layer_properties={ 'title':'Test_Comment_Layer', 'description':'This is a comment layer that is being used for testing purposes only', 'tags':'TPCM, Test, Python, Comment Layer' } gis.content.add(item_properties=layer_properties, data=base_comment_layer, folder='test_NF') but that didn't seem to work, I was getting an error: AttributeError: 'Item' object has no attribute 'replace' This is obviously after longing on using the GIS() method. Any adivice? Thanks.
... View more
03-03-2017
02:28 PM
|
1
|
3
|
4677
|
POST
|
I failed to read the ArcGIS Pro documentation and jumped straight into the API documentation. I never ran proenv and was probably doing things in a strange way. I fixed my issue and all is ok. Thanks!
... View more
03-01-2017
11:59 AM
|
1
|
0
|
572
|
POST
|
How would I update conda? Or resolve my issue with the numpy unicode escape error when I try to import numpy? Looks like I have an old version of conda that didn't accurately escape backslashes (see github ticket). Btw, I haven't done much as far as install or managing packages (didn't want to muck up ESRI's installation), maybe I should reinstall/repair the download? I may have accidently installed the arcgis API twice, though once through the package manager and once through command line. I don't know if that's an issue.
... View more
02-24-2017
11:21 AM
|
0
|
2
|
572
|
Title | Kudos | Posted |
---|---|---|
1 | 03-07-2017 09:49 AM | |
1 | 03-01-2017 11:59 AM | |
1 | 03-03-2017 02:28 PM | |
4 | 03-06-2017 11:00 AM | |
3 | 03-07-2017 09:18 AM |
Online Status |
Offline
|
Date Last Visited |
08-26-2021
11:40 PM
|