Skip to content

Simple case

Task description

For example you have dataset, where each object instance is segmented as masks. So each pixel is assigned to only one object instance. This case is applicable for such public datasets like (Pascal VOC or Mapillary).

Here is an example of image:

Opacity - 50 % Opacity - 100 %

Let's hide "Person" object. As you can see, "Car" object is the instance that consists of few not connected areas.

For example, you have dataset with lots of classes. And you want to drop all objects except cars (i.e. to train cars segmentation model).

There are few ways how we can drop classes inside Supervisely DTL. The result will be the same, but both ways are useful.

Way 1. Drop unnecessary classes in "data" layer.

Go to "DTL" and execute this DTL query:

[
  {
    "dst": "$sample",
    "src": [
      "my_project_masks/*"
    ],
    "action": "data",
    "settings": {
      "classes_mapping": {
        "car_bm": "__default__",
        "__other__": "__ignore__"
      }
    }
  },
  {
    "dst": "my_project_masks_only_car",
    "src": [
      "$sample"
    ],
    "action": "supervisely",
    "settings": {}
  }
]

This query is pretty simple. First "data" layer ("action": "data") defines the project we will transform. Also it defines classes_mapping, where car_bm class will be keeped and other classes will be dropped. The second layer ("action": "supervisely") just defines the name for resulting project - my_project_masks_only_car.

Way 2. Drop unnecessary classes in "drop_obj_by_class" layer.

Go to "DTL" and execute this DTL query:

[
  {
    "dst": "$sample",
    "src": [
      "my_project_masks/*"
    ],
    "action": "data",
    "settings": {
      "classes_mapping": "default"
    }
  },
  {
    "action": "drop_obj_by_class",
    "src": ["$sample" ],
    "dst": "$sample1",
    "settings": {
      "classes": ["person_bm"]
    }
  },
  {
    "dst": "my_project_masks_only_car_02",
    "src": [
      "$sample1"
    ],
    "action": "supervisely",
    "settings": {}
  }
]

The difference is that we didn't drop objects in "data" layer. We added "drop_obj_by_class" layer defined the list of classes we want to drop. This is useful when we want to use some objects in computational graph (i.e. to make some 'tricky' crops and flips based on those objects) but want to drop unnecessary objects at the end of transformation before saving results.