Deep Learning: cannot get arcgis.learn.install() to work

02-18-2022 06:21 AM
New Contributor II

I am attempting to save a deep learning model to my arcgis online account using arcgis.learn, then install the model to run on a raster. However, using the Model() function outputs <empty Model> even after I am able to fetch the model, and .install() outputs: 

RuntimeError                              Traceback (most recent call last)
In  [86]:
Line 1:     detect_objects_model.install()

File C:\Program Files\ArcGIS\Pro\bin\Python\envs\arcgispro-py3\Lib\site-packages\arcgis\learn\, in install:
Line 1412:  "model object should be created from a portal item or a portal url"

RuntimeError: model object should be created from a portal item or a portal url

I've set up my gis using my university portal and logged in successfully. I'm not sure why this is happening; it's doing this for every model. 


import arcgis
import sys
from arcgis import GIS, learn
from arcgis.raster import analytics
from arcgis.raster.functions import extract_band, apply, clip
from import list_datastore_content
from arcgis.learn import SingleShotDetector, prepare_data, Model, list_models, detect_objects 
arcgis.env.verbose = True
from arcgis.geocoding import geocode
import os
from pathlib import Path

gis = GIS('', '#####', '#####')

data_path = Path(r"I:\Other Maps\Deep_Learning\dl_trial1")
data = prepare_data(data_path, {0:'GBBG', 1:'HERG', 2:'DCCO'}, batch_size=162, no_check=True)

ssd = SingleShotDetector(data, grids=[8], zooms=[1.0], ratios=[[1.0, 1.0]])
ssd.lr_find(), lr=slice(2e-3, 3e-2))
ssd.show_results(thresh=0.8)'BirdDetector-ssd3', publish=True, gis=gis)
detect_objects_model = gis.content.get('4f22749c8265400ea560303dd708b90b')

detect_objects_model = Model(detect_objects_model_package)


 ArcGIS version 2.9.1.

0 Kudos
3 Replies
MVP Esteemed Contributor

Are you using these frameworks and instructions?

Esri/deep-learning-frameworks: Installation support for Deep Learning Frameworks for the ArcGIS Syst...

... sort of retired...
0 Kudos
New Contributor II

Yes, I've installed the deep learning installer (2.9) and all of the corresponding packages are installed. I was able to create a model, but I cannot use the following lines without throwing the runtime error provided above:

detect_objects_model = Model(detect_objects_model_package)


0 Kudos
Occasional Contributor III

The main problem is that detect_objects_model_package is not declared or populated anywhere in your script.

It should be something like (from this answer)

detect_objects_model_package = gis.content.get(item_id)
detect_objects_model = Model(detect_objects_model_package)

 You have hardcoded the AGOL ItemID as well - are you sure that's the correct one? Running the script again will probably give you a new ItemID each time.

0 Kudos