Last updated
Was this helpful?
Last updated
Was this helpful?
In this tutorial, you will learn how to import multispectral images to Supervisely using Python SDK and get the advantage of the grouped view in the labeling interface, which allows you to synchronize the view, zooming, panning, and labeling of images in one group.
You can also import multispectral images using app from Supervisely Ecosystem.
You will learn how to:
For the , you can use supervisely annotation JSON format to download and upload projects with multispectral images.
Everything you need to reproduce : source code and additional app files.
Step 3. Open the repository directory in Visual Studio Code.
Step 4. Change the Team ID and Workspace ID in the main.py
file by copying the ID from the context menu.
Step 5. Start debugging src/main.py
.
Supervisely instance version >= 6.8.54 Supervisely SDK version >= 6.72.201\
In the tutorial, Supervisely Python SDK version is not directly defined in the requirements.txt. But when developing your app, we recommend defining the SDK version in the requirements.txt.
To enable grouping of images, including view, zooming, panning and labeling, you need to set multispectral settings for the project. You can do it with just one line of code:
And now we're ready to upload images.
In this tutorial, we'll be using the api.image.upload_multispectral
method to upload images to Supervisely.
So, the method uploads images (which can be passed as channels or RGB images) to Supervisely and returns a list of ImageInfo
objects. RGB images as paths or channels as NumPy arrays can be passed to the method or both at the same time. The result will be a group of images in both cases.
Below, you will find examples of different ways to load multispectral data. However, it is important to note that you can group the images in any way you like: split them into channels, load them as a whole, or both at the same time. It is entirely up to you.
Input: 1 RGB image in PNG format.
Output: 3 images in a group with the name demo1.png
in Supervisely.\
We'll do this operation for other cases too, so let's take a closer look at the code:
The image_name
will be used as a group name in the labeling interface and it can be any string.
Then we read the image from the disk using OpenCV.
Now we're splitting the image into channels, and preparing a list of channels as NumPy arrays.
Finally, we upload the channels to Supervisely using the api.image.upload_multispectral
method.
So, those are the steps we'll be doing for all the other cases.
Input: 1 multichannel tiff image.
Output: 7 images in a group with the name demo2.tif
in Supervisely.\
In this tutorial, we'll be uploading the channels of nrrd image as separate images. But Supervisely supports high-dimensional nrrd images, so you can upload them as is without splitting them into channels.
Input: 1 nrrd image.
Output: 7 images in a group with the name demo3.nrrd
in Supervisely.\
Input: 1 RGB image and 1 thermal image in PNG format.
Output: 2 images in a group with the name demo4.png
in Supervisely.\
As you can see, in this case, we don't extract any channels since we need to upload only images, not channels. So, we pass the list of image paths to the rgb_images
parameter.
Input: 1 RGB image and 1 depth image in PNG format.
Output: 5 images in a group with the name demo5.png
in Supervisely.\
Here, we uploaded one image both as channels and as an image. So, we pass the list of image paths to the rgb_images
parameter and the list of channels to the channels
parameter.
Input: 1 grayscale image and 1 UV image in PNG format.
Output: 2 images in a group with the name demo6.png
in Supervisely.\
Input: 1 RGB image and 1 thermal image in PNG format.
Output: 5 images in a group with the name demo7.png
in Supervisely.\
Input: 1 RGB image and 2 MRI images in PNG format.
Output: 3 images in a group with the name demo8.png
in Supervisely.\
So now, that we've uploaded all the images, let's take a look at the labeling interface.
As you can see, all the images are grouped by the name of the group, which is the name of the image we passed to the image_name
parameter. We can zoom, pan, and label images in one group at the same time. So, whenever you create a label on one image, it will be automatically created on all the other images in the group. You can edit label on another image in the group, and it will be automatically updated on all the other images in the group. Just a reminder: we set the multispectral settings for the project at the beginning of the tutorial with the api.project.set_multispectral_settings
method, which enables this grouped view.
In this tutorial, you learned how to upload multispectral images to Supervisely using Python SDK and get the advantage of the grouped view in the labeling interface, which allows you to synchronize the view, zooming, panning, and labeling of images in one group. Let's recap the steps we did:
Create a new project and dataset.
Set multispectral settings for the project using the api.project.set_multispectral_settings
method.
Upload images using the api.image.upload_multispectral
method.
And that's it! Now you can upload your multispectral images to Supervisely using Python SDK.
This is very easy to see, if you want to group your images by the band
tag instead of im_id
(sync mode on), simply change your projectSettings
this way:
To download and upload a project using Supervisely SDK, use the following code:
Step 1. Prepare ~/supervisely.env
file with credentials.
Step 2. Clone the with source code and demo data and create a .
The method returns a list of ImageInfo
objects, which contain information about the uploaded images. Learn more about ImageInfo
.
You can always use to download to the local directory of your favorite multispectral project with the preserved multiview settings and then easily upload it as a new project to the
From the developer's point of view, the gives you easy access to the necessary parameters while grouping the images. To feel the power of this instrument, let's imagine the situation when you have already downloaded the project and opened the meta.json
file:
Moreover, you can additionally enhance your tags with hotkey
, or specify the tag classes
. See the explanation of every field .
dataset_id
int
ID of the dataset to upload
image_name
str
Name of the image will be used as name of the images group
channels
Optional[List[np.ndarray]] = None
List of channels as 2d numpy arrays.
rgb_images
Optional[List[str]] = None
List of paths to RGB images.