> ## Documentation Index
> Fetch the complete documentation index at: https://landinglens.docs.landing.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Load Images from Snowflake into LandingLens

export const vp = 'Visual Prompting';

export const smartLabel = 'Smart Labeling';

export const productLL = 'LandingLens';

export const mi = 'Mobile Inference';

export const llsf = 'LandingLens on Snowflake';

export const companyName = 'LandingAI';

*This article applies to these versions of LandingLens:*

<table>
  <thead>
    <tr>
      <th>LandingLens</th>
      <th>LandingLens on Snowflake</th>
    </tr>
  </thead>

  <tbody>
    <tr>
      <td><span class="cross-icon">✖</span></td>
      <td><span class="check-icon">✓</span></td>
    </tr>
  </tbody>
</table>

You can [use several methods](./upload-images) to upload images into a LandingLens project. When using {llsf}, 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](./load-images-from-snowflake#classify-images-when-loading-from-a-snowflake-stage) (in other words, upload labeled images).

<iframe width="560" height="315" src="https://www.youtube.com/embed/UWZEO843G9c??si=FvknmZeoaNarrJc8&wmode=opaque&rel=0" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen />

## Sync Snowflake Data Overview

When you use the **Sync Snowflake Data** workflow, you select a stage that you want to load images from. Images with [supported file types](./upload-images) 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.

The **Sync Snowflake Data** workflow can load up to 10,000 images. Images can be loaded 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).

## Prerequisite: 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, go to [Grant LandingLens Access to Stages](./grant-landinglens-access-to-stages).

The SQL commands will require the database, schema, stage, and LandingLens application name. If you're not sure if LandingLens has access to the stage or what the application name is, start setting up the sync in LandingLens. If you don't have access to the stage, the app will [give an error](./load-images-from-snowflake#troubleshooting-the-sync-process) and generate the SQL commands you need to run.

## Load Images with Sync Snowflake Data

After [granting LandingLens access](./grant-landinglens-access-to-stages) 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**.
   <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncSFData_1(1).png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=d348f7c9537d4561d846733c82944d18" alt="SyncSFData_1(1)" width="2350" height="674" data-path="images/SyncSFData_1(1).png" />
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**.
   <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncSFData_2(1).png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=fcf13499d2d6fb9e2ee4182c0f54cb07" alt="SyncSFData_2(1)" width="1158" height="1295" data-path="images/SyncSFData_2(1).png" />
6. Images from the stage (or the selected directories) are loaded to the LandingLens project in batches. The page refreshes every 10 seconds to display new images until all are loaded.
   <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncSFData_3.png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=84b0e8a5bd1c0cbddb3cbe8e01542dd6" alt="SyncSFData_3" width="2106" height="1288" data-path="images/SyncSFData_3.png" />

## 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](./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.

<Info>The **Sync Snowflake Data** tool doesn't upload labels/classes for Object Detection and Segmentation projects.</Info>

### 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.<br />
   **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.<br />
   **Example**: Inside `data`, create directories named `normal` and `pneumonia`.
3. Add images to the sub-directories based on class name.<br />
   **Example**: If you want an image to be classified as `normal` in LandingLens, add it to the `normal`directory. The directory in your stage would look like this:
   <img src="https://mintcdn.com/landinglens/AkXgdAcL19zbnV5n/images/directory_prep.png?fit=max&auto=format&n=AkXgdAcL19zbnV5n&q=85&s=f651d32c8969952cedc3e767f99e09b2" alt="directory_prep" width="407" height="139" data-path="images/directory_prep.png" />

### 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.
   <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncSF_classify_pneumonia_1.png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=32dfa45cb7447414925d195c8831e69a" alt="SyncSF_classify_pneumonia_1" width="1258" height="1444" data-path="images/SyncSF_classify_pneumonia_1.png" />
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.
  <img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncSF_classify_pneumonia_2.png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=1bcb3e1450daa1e631057089a0fe3ce2" alt="SyncSF_classify_pneumonia_2" width="2118" height="1014" data-path="images/SyncSF_classify_pneumonia_2.png" />

## 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:

* [Sample Dataset for LandingLens: Manufacturing Metal Casting](https://app.snowflake.com/marketplace/listing/GZTYZ12K65C6/)
* [Sample Dataset for LandingLens: LifeSciences Pneumonia](https://app.snowflake.com/marketplace/listing/GZTYZ12K65CA/)

## 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 that display on the pop-up.

<img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncFailedToLoad.png?fit=max&auto=format&n=PHcetUd-hiVs_otz&q=85&s=9dda74bc11921d3f0f588a2131a6bae5" alt="SyncFailedToLoad" width="1248" height="1668" data-path="images/SyncFailedToLoad.png" />

## 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.

<img src="https://mintcdn.com/landinglens/PHcetUd-hiVs_otz/images/SyncStatus_projec.gif?s=13553f3515a8c1138c7533d9f9bf9bd6" alt="SyncStatus_projec" width="1920" height="508" data-path="images/SyncStatus_projec.gif" />
