Esri / raster-deep-learning

ArcGIS built-in python raster functions for deep learning to get you started fast.
Apache License 2.0
186 stars 87 forks source link

AttributeError: '_thread._local' object has no attribute 'value' #33

Open ujwalakoriraj opened 3 years ago

ujwalakoriraj commented 3 years ago

I am trying to use the MRCNN sample for Object Detection and Instance Segmentation (Building Footprint detection). In the 'Detect Objects using Deep Learning' tool on Arcgis Pro, I am uploading the .emd file found in the 'examples' of 'MRCNN' folder in the 'Keras' folder. I have edited the .emd file by adding the full paths for "Architecture", 'Config', and 'ModelFile'. However, I have been encountering the error as follows, please help:


ERROR 002667 Unable to initialize python raster function with scalar arguments. [c:\program files\arcgis\pro\Resources\Raster\Functions\System\DeepLearning\ObjectDetector.py] Traceback (most recent call last): File "c:\program files\arcgis\pro\Resources\Raster\Functions\System\DeepLearning\ObjectDetector.py", line 54, in initialize self.json_info = json.load(f) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\building_project\Lib\json__init__.py", line 299, in load parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\building_project\Lib\json__init__.py", line 354, in loads return _default_decoder.decode(s) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\building_project\Lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\building_project\Lib\json\decoder.py", line 355, in raw_decode obj, end = self.scan_once(s, idx) json.decoder.JSONDecodeError: Invalid \escape: line 5 column 26 (char 107)

Unable to initialize python raster function with scalar arguments.


lingtangraster commented 3 years ago

Hi @ujwalakoriraj , could you post your emd file here?

ujwalakoriraj commented 3 years ago

Hello, I guess this particular issue I resolved, where the path's '\' character was treated as an escape character, and I placed another '\' character to escape the character itself, '\\'. However, I have run into another error now (please help):


ERROR 002667 Unable to initialize python raster function with scalar arguments. [c:\program files\arcgis\pro\Resources\Raster\Functions\System\DeepLearning\ObjectDetector.py] Traceback (most recent call last): File "c:\program files\arcgis\pro\Resources\Raster\Functions\System\DeepLearning\ObjectDetector.py", line 84, in initialize self.child_object_detector.initialize(model, model_as_file) File "c:\program files\arcgis\pro\Resources\Raster\Functions\System\DeepLearning\Keras\MaskRCNN.py", line 48, in initialize self.config = getattr(importlib.import_module(config_module_name), 'config') File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\test1_DL\Lib\importlib__init.py", line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "", line 994, in _gcd_import File "", line 971, in _find_and_load File "", line 955, in _find_and_load_unlocked File "", line 665, in _load_unlocked File "", line 678, in exec_module File "", line 219, in _call_with_frames_removed File "D:\python\building_detection\1_building_arcgis\raster-deep-learning-master\examples\keras\mask_rcnn\mrcnn\spacenet.py", line 27, in model = modellib.MaskRCNN(mode='inference', config=config, model_dir='./') File "D:\python\building_detection\1_building_arcgis\raster-deep-learning-master\examples\keras\mask_rcnn\mrcnn\model.py", line 1849, in init self.keras_model = self.build(mode=mode, config=config) File "D:\python\building_detection\1_building_arcgis\raster-deep-learning-master\examples\keras\mask_rcnn\mrcnn\model.py", line 1869, in build shape=[None, None, 3], name="input_image") File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\test1_DL\Lib\site-packages\keras\engine\input_layer.py", line 178, in Input input_tensor=tensor) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\test1_DL\Lib\site-packages\keras\legacy\interfaces.py", line 91, in wrapper return func(*args, **kwargs) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\test1_DL\Lib\site-packages\keras\engine\input_layer.py", line 87, in init__ name=self.name) File "C:\Users\rajak\AppData\Local\ESRI\conda\envs\test1_DL\Lib\site-packages\keras\backend\tensorflow_backend.py", line 73, in symbolic_fn_wrapper if _SYMBOLIC_SCOPE.value: AttributeError: '_thread._local' object has no attribute 'value'

Unable to initialize python raster function with scalar arguments.


ujwalakoriraj commented 3 years ago

Please help me if you can.

xuxucmkox commented 3 years ago

Please help me if you can.

@ujwalakoriraj can you tell us what Pro version you are using? Also what is the pytorch, tensorflow version your python environment has? You can check this via "settings" -> "Python" -> "installed packages"

ujwalakoriraj commented 3 years ago

Sure. Pro version - 2.6.0 Pytorch version: 1.4.0 tensorflow-gpu version=2.1.0

xuxucmkox commented 3 years ago

Sure. Pro version - 2.6.0 Pytorch version: 1.4.0 tensorflow-gpu version=2.1.0

@ujwalakoriraj The dependencies should be good. Did you use the built-in python raster function that comes with Pro 2.6, or did you use the ones in this repo? We have not updated this repo to keep these python raster functions consistent with what Pro has. The ones in Pro should have no problem to do inference. Also Keras version should be 2.3.1.

ujwalakoriraj commented 3 years ago

I used the built-in python raster function in this repo. How do I use the one with Arcgis Pro?

That's right, the Keras version is 2.3.1

xuxucmkox commented 3 years ago

I used the built-in python raster function in this repo. How do I use the one with Arcgis Pro?

That's right, the Keras version is 2.3.1

It's under \ArcGIS\Resources\Raster\Functions\System\DeepLearning. The ones in Pro are up-to-date.