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.jpgYou 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:
File selector to select folder with data.
Import settings.
Destination project settings.
Output card with button to start import and info about result project.
Let's take a closer look at each step:
Create FileSelector widget to select folder with data and place it into Card widget with validation.
Create Checkbox widget to select if we want to remove source files after successful import and place it into Card widget.
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.
Create Button widget to start import process.
Create output text to show warnings and info messages.
Create progress widget to show progress of import process.
Create ProjectThumbnail to show result project with link to it.
Combine all button, output text, progress and project thumbnail .
Create layout by combining all created cards into one container.
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
.gitignoreto exclude it from the list of files tracked by Git.
Last updated
Was this helpful?