Load Images from Snowflake into LandingLens
  • 10 Sep 2024
  • 5 Minutes to read
  • Dark
    Light
  • PDF

Load Images from Snowflake into LandingLens

  • Dark
    Light
  • PDF

Article summary

This article applies to these versions of LandingLens:

LandingLensLandingLens on Snowflake

You can use several methods to upload images into a LandingLens project. When using LandingLens on Snowflake, you can load images from a Snowflake stage into a LandingLens project using Sync Snowflake Data.

If you're in a Classification project, you can use this tool to classify images at upload (in other words, upload labeled images).

Sync Snowflake Data Tool

Sync Snowflake Data Overview

When you use the Sync Snowflake Data workflow, you select a stage that you want to load images from. All images with supported file types in the selected Snowflake stage are loaded into the LandingLens project. If the stage has directories, images in those directories are also loaded into LandingLens.

You can load data from both internal and external stages.

The Sync Snowflake Data tool only transfers data into LandingLens; it doesn't load data from LandingLens into Snowflake.

Additionally, Sync Snowflake Data only loads data each time it's run. For example, if you run Sync Snowflake Data and later add more images to the stage, those images aren't automatically loaded into LandingLens. However, manually running Sync Snowflake Data again will load the new images (it will ignore any images that have already been added to LandingLens).

Grant LandingLens Access to a Stage

Before you can load images from a stage into a LandingLens project, you must first run SQL commands to grant LandingLens access to that stage. To do this:

  1. Make a note of the database, schema, and stage that have the images you want to load into LandingLens.
  2. Open a worksheet in Snowsight and run the following SQL commands. Replace the YOUR_DB, YOUR_SCHEMA, YOUR_STAGE, and <THIS APPLICATION NAME>  placeholders with your information. (If you're not sure what the location or application names are, you can get this information when setting up the sync in LandingLens. During that process, the app generates SQL commands with the location and application names.)
    GRANT USAGE ON DATABASE YOUR_DB TO APPLICATION <THIS APPLICATION NAME>;
    GRANT USAGE ON SCHEMA YOUR_DB.YOUR_SCHEMA TO APPLICATION <THIS APPLICATION NAME>;
    GRANT READ ON STAGE YOUR_DB.YOUR_SCHEMA.YOUR_STAGE TO APPLICATION <THIS APPLICATION NAME>;

Load Images with Sync Snowflake Data

After granting LandingLens access to the stage with the images you want to load into LandingLens, you can load those images into a LandingLens project.

  1. Open the project you want to load images to.
  2. Click Sync Snowflake Data.
    Sync Snowflake Data
  3. Enter the database, schema, and stage that have the images you want to load into LandingLens. The drop-downs automatically populate based on the locations that you created or have access to.
  4. Click the directory path (⌄ /) in the Folder box. Use this field to navigate to and select a directory on the Snowflake stage.
    • If you select the root directory (or don't select any directory), supported images from the stage and its directories will be loaded into LandingLens.
    • If you want to load images from only a specific directory, select that directory.
  5. Click Sync.
    Load Images from the Selected Directory
  6. All images in the stage (or the selected directories) are loaded to the LandingLens project. Refresh the page to see the images.
    Images Are Loaded into the Project

Classify Images When Loading from a Snowflake Stage

If you're in a Classification project, you can automatically assign classes to images based on directory names when uploading data from a Snowflake stage. The approach is similar to how you classify images when uploading directories from your hard drive, as explained in Classification.

You will need to first create directories and add images to them in the Snowflake stage. Then, you will select the directories when using the Sync Snowflake Data workflow.

Note:
The Sync Snowflake Data tool doesn't upload labels/classes for Object Detection and Segmentation projects.

Set Up Directories in Snowflake

To classify images at upload, first organize the directories and images in a Snowflake stage:

  1. Create a directory in a Snowflake stage. This will be your "root" directory.
    Example: Create a directory named data.
  2. Inside your root directory, create a sub-directory for each class you want to use. Name the sub-directories after the classes.
    Example: Inside data, create directories named normal and pneumonia.
  3. Add images to the sub-directories based on class name.
    Example: If you want an image to be classified as normal in LandingLens, add it to the normaldirectory. The directory in your stage would look like this:
    Sample Directory Structure

Load and Classify Images from Directories

When you're ready to load images from the Snowflake stage, click Sync Snowflake Data and configure the settings:

  1. Select the Database, Schema, and Stage.
  2. Turn on Classify images based on folder names
  3. Click the directory path (⌄ /) in the Folder box.
  4. Select the "root directory" that you created. For example, in the screenshot below, select data. Do NOT select the directory that actually contains the images.
    Sync the "Root" Directory
  5. After loading the data, you will see that:
    • LandingLens created a class based on each sub-directory name (if the classes didn't exist yet).
    • Images in each sub-directory will be in LandingLens and will be classified with the name of their directory. For example, in the screenshot below, the "pneumonia" class is assigned to the images.
      LandingLens Assigns the Directory Name as the Class for the Images in That Directory

Sample Datasets

LandingLens offers two sample datasets that you can use to practice loading and classifying images from Snowflake stages. These datasets are available as "apps" from the Snowflake Marketplace. Access the datasets here:

Troubleshooting the Sync Process

When using Sync Snowflake Data tool , you might get this error:

Failed to load folder list, Failed to list folder. Please follow instruction below to grant permission to the stage.

This error means that you don't have permission to access the Database, Schema, or Stage you selected. To get permission, run the generated SQL commands.

Run the SQL Commands to Access the Stage

View Syncs from the Past Seven Days

If you've run the Sync Snowflake Data tool in a project, you can see the status of all syncs from the past seven days. To do this, click the Sync icon near the top right corner LandingLens. A list of all syncs, the synced stages, and statuses display.

Hover over a stage to see the full path of the database, schema, and stage.

If a sync failed, hover over the i icon to see more details.

Sync Statuses

Was this article helpful?