PySDK Basics: Running Your First Hosted Inference

In this user guide, we will explain how to run inference on the DeGirum AI Hub.

To run inference on an image using PySDK, you need the following:

  • model_name: The name of the machine learning model. In this example, we will use mobilenet_v2_ssd_coco model compiled for DeGirum’s Orca.
  • inference_host_address: Address of the hardware running the ML model.
  • zoo_url: The url of the zoo which contains the model. In this example, we will use DeGirum’s public model zoo.
  • cloud_token: A token to access DeGirum AI Hub. See here for instructions to generate a token.
  • image_source: URL or path or PIL image object or NumPy array

The code below shows a Jupyter Notebook cell that illustrates how to run inference:

import degirum as dg
model = dg.load_model(
    model_name='mobilenet_v2_ssd_coco--300x300_quant_n2x_orca1_1',
    inference_host_address='@cloud',
    zoo_url='degirum/public',
    token=cloud_token,
)
image_source = 'https://raw.githubusercontent.com/DeGirum/PySDKExamples/main/images/TwoCats.jpg' 
res=model(image_source)
res.image_overlay

Running the code should give a result as below:

pysdk_example

Related Examples