I have already run 'register_coco_instances' for registering my dataset.

But when I tried to run 'register_coco_instances' again because I changed the json file, I encountered the error "AssertionError: Dataset 'xx_train' is already registered!"

How can I re-run register_coco_instances although previous register.

Thanks.

I have no idea. So run time off and try again.

1

There are 1 best solutions below

0
On

Based on this github comment: https://github.com/facebookresearch/detectron2/issues/1647#issuecomment-735790186

you can check if the dataset name is inside the DatasetCatalog.list():

from detectron2.data import DatasetCatalog

dataset_name = 'coco_dataset'

if dataset_name in DatasetCatalog.list():
    DatasetCatalog.remove(dataset_name)

register_coco_instances(dataset_name, ...)

in my case I did check if the dataset was not in the list then I registered it:

from detectron2.data import DatasetCatalog

dataset_name = 'coco_dataset'

if not dataset_name in DatasetCatalog.list():
    register_coco_instances(dataset_name, ...)