Hey everyone (and @KarthikDutt, who asked me to post this here!)
I ran into an issue while using Jupyter Notebook and arcgis.learn for the first time while following this Esri Youtube Video
I found the github location for the workflow and tried following the documentation but ran into dependency installation issues and deep learning tool model existence in certain versions of Anaconda.
I could not get this to work in a Jupyter Notebook. Maybe someone might have some insight!
I downloaded Anaconda, version 3.8, and installed ArcGIS API for Python (arcgis) per the blog "Three Ways to Get Jupyter Notebooks and the ArcGIS API for Python".
With my data in a notebook, I tried according to the video at timestamp 2:07:
ln: from arcgis.learn import prepare_data, MultiTaskRoadExtractor
ln: data_path=..... <<(I selected the path where my image chips were stored)
ln: data = prepare_data(data_path, chip_size=256, batch_size=135)
I received a traceback error on ln saying I was missing a number of dependencies required to use MultiTaskRoadExtractor. So, I opened the Anaconda command prompt and tried installing them, only to be told that there were a bunch of conflicts that prevented install.
So I researched how to create new Anaconda environments, and created one for Python 3.6, because some forums said some dependencies like earlier versions better. I installed arcgis so I could access Jupyter Notebooks in Python 3.6. Also, in my Python 3.6 environment, the dependencies now installed without issue. But then when I tried the above code again in a 3.6 Notebook, ln returned a traceback error saying:
"ImportError: cannot import name 'MultiTaskRoadExtractor' from 'arcgis.learn' (C:\Users\JohnC\anaconda3\envs\snakes\lib\site-packages\arcgis\learn\__init__.py)"
To see if there was a model existence issue, I compared the 'lib\site-packages\arcgis\learn\__init__.py" files between environments, and the Python 3.6 environment did not have the MultiTaskRoadExtractor model. Version 3.8 does.
So I tried creating another anaconda environment in Version 3.7 to see if I could install these model dependencies and see if the MultiTaskRoadExtractor model was available for import into a Notebook. It also was not. It seems only Version 3.8 has this model, but the dependencies also won't download to the 3.8 environment.
So I'm unsure what to do, and I've exhausted my level of knowledge with this stuff (which is next to nothing).
Do you have any suggestions? Is there more information you need from me to answer this? Let me know and thank you in advance.
Solved! Go to Solution.
Can you replace the arcgis API version in the installation command and try again.
conda install -c esri -c fastai -c pytorch arcgis=1.8.4 scikit-image=0.15.0 pillow=6.2.2 libtiff=4.0.10 fastai=1.0.60 pytorch=1.4.0 torchvision=0.5.0 --no-pin
Did you check the following section in that link?
Setting up the environment
You might want to check out the github site as well
So, I got it to work, but only when using a notebook within ArcGIS Pro. After installing the Deep Learning Frameworks to my ArcGIS Pro install, I was able to use the MultiTaskRoadExtractor model within the program, because all of the necessary libraries were finally available.
Trying to use the model in a Jupyter Notebook through a web browser tab, activated by my Anaconda Command Prompt still does not work, because of the weird dependency install issues.
whatever environment is activated through your conda prompt would also have to have all the dependencies installed.
Deep learning .... makes you wonder sometimes 😉
That was the issue. I tried installing the dependencies on three environments: default (v3.8), "rattler" (v3.6), and "snakes" (3.7). They installed on 3.6 and 3.7 without issue, but wouldn't install on 3.8. The arcgis package installed on each version without issue, but versions 3.6 and 3.7 didn't include the MultiTaskRoadExtractor model, so I couldn't use those versions to run a jupyter notebook. So my only option was my 3.8 environment, which wouldn't install the dependencies.
Haha, deep learning indeed. Maybe one day it can deep learn my issues and solve 'em for me!
some of the deep learning packages aren't/weren't supported in python 3.8 (tensorflow is one if memory serves).
I suspect they have been slowing up arcpy upgrades which is why 3.7 is the version for arcgis pro 2.7.
MultiTaskRoadExtractor model was added in ArcGIS Python API version 1.8.1, any subsequent release will have that. Can you also attach output of conda list from your env where it is not working.