Skip to main content
This article applies to these versions of LandingLens:
LandingLensLandingLens on Snowflake
After deploying a model with Cloud Deployment, you can run inference using this function, where APP_NAME is the name of your LandingLens instance:
Here is how you select the function:

Prerequisites

Arguments

file_path A VARCHAR string that defines the location of an image or set of images to run inference on. This can be:
  • images in Snowflake, including images in tables
  • publicly-available HTTP/HTTPS URLs, including publicly-available Amazon S3 URLs
endpoint_id A VARCHAR string that defines the endpoint of a model deployed with Cloud Deployment. The endpoint_id displays on the Deploy page in LandingLens. sf_endpoint

Run Inference on Multiple Images

To use the run_inference function to run inference on multiple images, the image filepaths must be in a table or table-like format. For example, you can use the LIST command to list all files in a stage in a table-like format. You can then incorporate the LIST command results in the run_inference function. For more information, see this example.

Inference Function Results

Running inference with the function returns prediction results in a JSON format. This is the same format that is returned when running Cloud Deployment using any other method. sf_inference_url_results_json The image and the prediction also display on the Deploy page in LandingLens (refresh the page in LandingLens to see the results). sf_inference_url_results_ll

Locate the Function

LandingLens automatically generates the inference function that is populated with the name of your instance of LandingLens. You can get the function for your instance of LandingLens in Snowsight:
  1. Open Snowsight.
  2. Go to Data Products > Apps > LandingLens Visual AI Platform.
  3. Click Launch App. locate_inference_statement_1
  4. Click APP_WIZARD.
  5. Click Settings.
  6. Expand the Run inferences from SQL statement section. The custom inference function for your instance of LandingLens displays. locate_inference_statement_2

Example: Run Inference on an Image Online

The function can run inference on publicly-available HTTP/HTTPS URLs. For example:

Example: Run Inference on an Image in Snowflake

Let’s say you’ve installed the Sample Dataset for LandingLens: LifeSciences Pneumonia dataset from LandingAI. You can then run inference on images from that dataset. For example:

Example: Run Inference on Images in a Snowflake Table

You can run inference on images in a Snowflake table. For example:

Example: Add Images from a Stage to a Table and Run Inference

Let’s say you want to run inference on multiple images in a Snowflake stage and save the results of the model’s predictions. You can do this by running a series of SQL commands that:
  1. create a table,
  2. add the image file names to that table,
  3. run inference, and
  4. save the prediction results to that table.
To make this easier to understand, we’ve created a SQL script below that shows how to do this based on the Sample Dataset for LandingLens: LifeSciences Pneumonia dataset from LandingAI. The script explains how to run inference on the first 20 images in that dataset. Modify the script as needed for your use case.

Prerequisites

Here are a set of prerequisites to consider when you’re running the script on the sample dataset and when you’re running it on your own dataset.

Sample SQL Script

You can copy and paste the following SQL script into a Worksheet in Snowsight. Update the placeholders that are called out in the commented parts of the code.