Cloud Deployment
  • 13 Mar 2023
  • 8 Minutes to read
  • Dark
    Light
  • PDF

Cloud Deployment

  • Dark
    Light
  • PDF

Overview

After you are happy with the results of your trained Model, you are ready to use it! To use a Model, you deploy it, which means you put the Model in a virtual location so that you can then upload images to it. When you upload images, the Model runs inferences, which means that it detects what it was trained to look for.

The quickest and easiest deployment method is Cloud Deployment. At a high level, Cloud Deployment is the deployment tool built directly into LandingLens. You can set up the deployment in seconds, upload images, and see the predictions right away in LandingLens. 

Now let's take a closer look at the Cloud Deployment process. First, you create an endpoint, which is a virtual device. The Model you select for the deployment will run on that device. Next, you upload images to the endpoint, and the Model runs inferences. The results then display in the interface. 

In addition to uploading images to an endpoint through the user interface, you can also upload images through an API call. For more information, go to Send Images to Endpoints Using API.

Set Up Endpoints

The first part of Cloud Deployment is setting up an endpoint. You can set up multiple endpoints. This lets you run different Models. You can change the Model used for an endpoint at any time. However, endpoints can't be renamed or deleted. 

To set up an endpoint:

  1. Open the Project.
  2. Click Deploy.
    Open the Deploy Page
  3. If you haven't created any endpoints for the Project yet, you are prompted to do so. If you've already created endpoints, click Create Endpoint.
    Create Endpoint
  4. Enter a brief, descriptive name for the endpoint and click Create.
    Name the Endpoint
  5. Select a Model to use from the Model drop-down menu. This is the Model that will be used to run inferences.
  6. If needed, adjust the Confidence Level.
  7. Click Deploy.
    Set Up and Deploy the Endpoint
  8. LandingLens creates the endpoint. You can now use this endpoint to run inferences.
    The Endpoint Is Ready to Be Used

Test the Inference Process (Predict)

After you set up an endpoint, you can test the inference process using the Predict tool. To do this, you click Predict, select a few images directly through the user interface, and the Model detects what it was trained to look for. 

You can review the results to check if your Model runs correctly. If the results aren't as precise as you'd like, you can go back to the Build tab and fine-tune your Model. Or, if the results look good, you can deploy your Model on a larger scale through API or LandingEdge

Since Predict is only for testing, the results aren't saved to your Project. 

To test the inference process:

  1. Open the Project.
  2. Click Deploy.
  3. Select the endpoint you want to use.
  4. Click Predict.
    Predict
  5. Upload images. 
  6. LandingLens runs the model and shows you the results. You can:
  1. View the predicted areas.
    Predicted Areas Are Marked
  2. Hover over the Confidence Threshold slider to see the Data Performance graph of the Model. For more information about this graph, go to Confidence Threshold
    See the Data Performance Graph
  3. Adjust the Confidence Threshold. Then click Update Threshold to update the Model and redeploy. Or click Reset to return to the original threshold. For more information about the threshold, go to Confidence Threshold
    Update the Confidence Threshold
  4. Click JSON output to see the coordinates of the labels. For more information, go to JSON Output.
    JSON Output
  5. Click the Upload or Webcam icon to run inference on more images.
    Upload More Images

JSON Output

When you run inference through the Predict tool, you have the option to see the coordinates of the bounding boxes as JSON. To do this, run inference and click JSON Output.

The code includes the following information:

  • mediaId: A unique identifier that LandingLens assigns to each image.  
  • defectId: A unique identifier that LandingLens assigns to each detected area. 
  • score: The Confidence Score, which indicates how confident the AI is that its prediction is correct for a specific detected area.
  • coordinates: The x and y coordinates of the edges of a label's bounding box. For more information, go to Coordinates.

Coordinates

The JSON output includes one section for each bounding box (detected area) the Model adds. Each section includes the coordinates of the pixels for each corner of the bounding box. The origin for the coordinates is the top left corner of the image. 

For example, let's say that this is the JSON output for an image:

{
   "mediaId": 8706335,
   "label": [
      {
         "defectId": 52479,
         "score": 0.99,
         "coordinates": {
            "xmin": 787,
            "ymin": 1078,
            "xmax": 1229,
            "ymax": 1594
         }
      }
   ]
}

The coordinates correspond to the points described in the following table and image.

NameDescriptionCoordinate (in pixels)
xminThe distance from the left edge of the image to the left side of the bounding box.787
yminThe distance from the top of the image to the top side of the bounding box.1078
xmaxThe distance from the left edge of the image to the right side of the bounding box.1229
ymaxThe distance from the top of the image to the bottom side of the bounding box.1594
The Coordinates Correspond to the Edges of the Bounding Box

Run Inference Using API

After you create an endpoint, you can run inference by running an API call. This method also saves the images to your Project, so that you can review the results and even save images to your dataset. 

To run inference using an API call:

  1. Open the Project.
  2. Click Deploy.
  3. Select the endpoint you want to use.
  4. Click Copy to save the API call to your clipboard.  (You can also click View API Command and copy the call from the pop-up window that opens.)
    Copy the API Call
  5. Paste the API call into your API platform.
  6. Update the apikey and apisecret parameters with your API Key and API Secret. To generate these credentials, go to API Key and API Secret.
  7. Update the fileparameter with the image file names you want to run inference on. For example, after updating the parameters, your API call could look like this:
    curl --location --request POST 'https://predict.app.landing.ai/inference/v1/predict?endpoint_id=12a3bc4d-ef56-7ghi-89jk-123lm4n456789' \
         --header 'Content-Type: multipart/form-data' \
         --header 'apikey: dv9i0feqgoymhobrc9a6wr1yeo83s2i' \
         --header 'apisecret: xi25sgrdcy83m6d0xicgdzw75dz4yhoa1ad0vzipd07p0mc999iaawabjcp0bm' \
         --form 'file=@"manufacturing_qa_123.jpeg"'
  8. Run the API call.
  9. In LandingLens, open the Project to the Deploy page (if it's already open, you can refresh the page). The results display in the Historical Data tab.

Example: Run the API Call from Postman

Note:
The procedure in this section is based on the user interface of Postman at the time of this article’s publication. However, this interface may change over time. Refer to the Postman documentation for the current information about how to use this application.

There are several ways to run the API call to run inferences. If you're not familiar with APIs, or you just want to test out the API call, you can run the API call from Postman. Postman is a third-party application that, among other things, lets you run API calls for free. Landing AI isn't affiliated with Postman, and we recommend you do your own research to determine if this tool is right for you. 

The following example is intended only to show you one of the ways to run the deployment API.

Set Up Postman

  1. Sign up for a free version of Postman. 
  2. Select the Browser version (web app) and download the Postman Agent. For more information, check out the Postman installation instructions
  3. After the agent is installed, go to this folder on your computer: /Users/username/Postman Agent.
  4. Rename the Postman Agent folder to Postman.
    Note:
    Renaming the folder is a workaround to an issue in Postman. By default, Postman can only access files in this directory:  ~Postman/files. However, installing the Postman Agent creates this directory: ~Postman Agent/files. If you don't rename the folder, Postman can't access the files that you want to send to LandingLens for inference.
  5. Add the files that you want to run inference on to this folder: /Users/username/Postman/files.

Run the API Call

  1. Open the Postman web app in your browser. 
  2. Go to My Workspace.
  3. Click Import in the left side bar.
    Import the API Call
  4. Click Raw text.
  5. Paste your API call in the text field. You can leave the file=@"YOUR IMAGE" parameter as-is, because you will select the image files later.
    Paste in the API Call
  6. Click Continue.
  7. Click Import.
    Import
  8. Postman fills out the parameters in the user interface based on the API call you submitted. You can view this information on the Post, Params, Header, and Body sections.
    View the Filled-Out Sections
  9. Click Body.
  10. Click Select Values.
    Select the Images to Run Inference On
  11. Go to the /Users/username/Postman/files directory and select the files you want to run inference on. 
  12. The files display in the Value column.
  13. Click Send.
    Send the API Call
  14. The response displays at the bottom of the page.
    View the Response in Postman
  15. In LandingLens, open the Project to the Deploy page (if it's already open, you can refresh the page). The results display in the Historical Data section.
    View the Image and Data in LandingLens

API Key and API Secret

If you send images to an endpoint through API, you must add your API Key and API Secret to the API call. You can generate the API Key and API Secret in LandingLens. The API Key and API Secret are only valid within the same organization in LandingLens. If you work with different organizations, you must generate credentials for all accounts. 

After you generate the API Key and API Secret, you can regenerate these credentials if needed. Regenerating the credentials overrides the existing API Key and API Secret, so make sure you update any API calls you're using.

To generate your organization's API Key and API Secret:

  1. Open the Project.
  2. Click Deploy.
  3. Click API Key / Secret on the left side of the page, or click View API Key & Secret at the bottom of the page.
    View the API Key and API Secret
  4. Click Generate API Key.
    Generate API Key
  5. A pop-up window displays with the API Key and Secret credentials. Save these credentials.
    Copy the API Key and API Secret
  6. Click OK to close the window.
  7. To later retrieve the API Secret and API Key, open the Deploy page and click the Copy icon. This saves the credential to your clipboard. 

Deploy Directly from a Model

In addition to running Cloud Deployments from the Deploy page, you can also run them from the Build page. There are two ways to do this:

  • When you save a Model, LandingLens prompts you to deploy it. You can select an existing endpoint or create a new one.
    Select or Create an Endpoint
  • Click Models, select the Model you want to use, and click Deploy. You can select an existing endpoint or create a new one.
    Deploy a Model from the Build Page

Was this article helpful?