pythonobject-detectionimage-segmentationmultiple-instancescoco

How to train Detectron2 model with multiple custom dataset


I would like to train the detectron2 model with registering multiple datasets

I have extracted my annotations from the different tasks and now I have multiple datasets which we need to be trained together.

Datasets Folder
Task1 -- annotations.json
      -- image dir
Task2 -- annotations.json
      -- image dir
Task3 -- annotations.json
      -- image dir
Task4 -- annotations.json
      -- image dir

My question is whether we can train the model with multiple datasets. Can we register multiple coco instances for training? I would like to train my model on Task1 Task2 Task3 and test on task4

from detectron2.data.datasets import register_coco_instances
register_coco_instances("train", {}," ./Task1/annotations.json", "./Task1/imagedir")
register_coco_instances("Test", {}, "./Task4/annotations.json", "./Task4/imagedir")

Or Do I need to combine all the coco instances!

please provide your inputs


Solution

  • Answering my own question. Apparently, there is no such method to try the multiple datasets. If you like to combine different datasets then use the COCO Assitant library.

    Simple step to install is:

    !pip install coco-assistant