From scratch - simple

A step-by-step tutorial of how to create custom import Supervisely app from scratch.

Introduction

In this tutorial, we will create a simple import app that will import images from selected folder to Supervisely server. This application is headless (no GUI) and is designed to demonstrate the basic principles of creating minimalistic import applications.

Data example

πŸ“‚my_folder
┣ πŸ–ΌοΈcat_1.jpg
┣ πŸ–ΌοΈcat_2.jpg
β”— πŸ–ΌοΈcat_3.jpg

You can find the above demo files in the data directory of the template-import-app repo - here

Tutorial content

Everything you need to reproduce this tutorial is on GitHub: main.py.

Before we begin, please clone the project and set up the working environment - here is a link with a description of the steps.

Step 1. How to debug import app

Open local.env and set up environment variables by inserting your values here for debugging. Learn more about environment variables in our guide

local.env:

Step 2. How to write import script

Find source code for this example - main.py

Step 1. Import libraries

Step 2. Load environment variables

Load ENV variables for debug, has no effect in production.

Step 3. Initialize API object

Create API object to communicate with Supervisely Server and initialize application. Loads from supervisely.env file

Step 4. Create new project and dataset on Supervisely server

Step 5. Download data from Supervisely server

Check if app was launched in production mode and download data from Supervisely server

Step 6. List files in directory

Get list of files in directory and create list of images names and paths

Step 7. Upload images to new project

Output of the app in development mode:

Step 3. Advanced debug

Advanced debug is for final app testing. In this case, import app will download data from Supervisely server. You can use this mode to test your app before publishing it to the Ecosystem.

To switch between local and advanced debug modes, select corresponding debug configuration in Run & Debug menu in VS Code

Open advanced.env and set up environment variables by inserting your values here for debugging.

advanced.env:

Please note that the path you specify in the SLY_APP_DATA_DIR variable will be used for storing import data.

For example:

  • path on your local computer could be /Users/admin/projects/import-app-from-scratch/input/

  • path in the current project folder on your local computer could be input/

Also note that all paths on Supervisely server are absolute and start from '/' symbol, so you need to specify the full path to the folder, for example /data/my_folder/

Don't forget to add this path to .gitignore to exclude it from the list of files tracked by Git.

Output of the app in production mode:

Last updated

Was this helpful?