From scratch GUI - advanced

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

Introduction

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

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. Loads from supervisely.env file

Step 4. Make GUI with widgets

We will build GUI for our import app using Supervisely widgets.

We will breakdown our GUI into 4 steps:

  1. File selector to select folder with data.

  2. Import settings.

  3. Destination project settings.

  4. Output card with button to start import and info about result project.

Let's take a closer look at each step:

  1. Create FileSelector widget to select folder with data and place it into Card widget with validation.

  2. Create Checkbox widget to select if we want to remove source files after successful import and place it into Card widget.

  3. Create workspace selector and input widget to enter project name. Combine those widgets into Container widget and place it into Card widget. Using workspace selector we can select team and workspace where we want to create project in which data will be imported.

  4. Create Button widget to start import process.

  5. Create output text to show warnings and info messages.

  6. Create progress widget to show progress of import process.

  7. Create ProjectThumbnail to show result project with link to it.

  8. Combine all button, output text, progress and project thumbnail .

  9. Create layout by combining all created cards into one container.

  10. Initialize app object with layout as an argument.

Step 5. Add button click handler to start import process

In this step we will create button click handler. We will get state of all widgets and import data to new project.

App screenshot

Step 3. Advanced debug

Advanced debug is for final app testing. In this case, import app will download selected folder with 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-gui/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.

Advanced debug

Last updated

Was this helpful?