slice()

Slice the data of a directory by a given query.

Introduction

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.

Example

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

Query Syntax

Query Syntax Reference

Getting Started

After calling slice() you have a dataset object.

You can then call list_files() on that dataset.

Parameters:

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

Returns

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

Demo

You can try the explorer and query engine here: Coco Demo