Slice the data of a directory by a given query.

Slices the data based on the given query. The query is based on our Dataset Explorer feature, so any query that's working on our dataset explorer, should also work on the slice() method.

You can try the explorer and query engine here:


  • query (str): the string of the query to slice the dataset.


A SlicedDirectory object. This object inherits from Directory classs, so all functionality and methods available in directory, are also available on SlicedDirectory objects.

dataset = project.dataset.get('my dataset')
# Get only the images with more than 3 cars and at least one pedestrian
sliced_dataset = dataset.slice(' > 3 and labels.pedestrian >= 1')