datumaro icon indicating copy to clipboard operation
datumaro copied to clipboard

Delete class from dataset

Open tdhooghe opened this issue 2 years ago • 2 comments

Hi,

First of all, thank you for this amazing dataset management framework!

I was wondering how I could delete a class from my dataset. I have two empty classes in my current dataset since it belongs to a CVAT project that represents the final dataset containing all classes of my interest. Keeping these empty classes in my dataset does not work well with training a model.

Kind regards, Thomas

tdhooghe avatar Jul 12 '22 11:07 tdhooghe

Hi! There are 2 options available: use remap_labels or project_labels transforms.

From CLI you can do it this way:

datum create
datum import -f <format> <path>
datum transform -t remap_labels -l "cat:" -l "dog:" # --overwrite or -o <dst_dir>

From Python API you can use it like this:

import datumaro as dm
dataset = dm.Dataset.import_from('path', 'format')
dataset.transform('remap_labels', mapping={'cat': '', 'dog': ''})
dataset.export('path2', 'format')

zhiltsov-max avatar Jul 12 '22 14:07 zhiltsov-max

Great, thank you!

tdhooghe avatar Jul 14 '22 07:07 tdhooghe