yogi
yogi

Reputation: 93

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

Upvotes: 1

Views: 2553

Answers (2)

Lucien Murray-Pitts
Lucien Murray-Pitts

Reputation: 301

Actually its possible to train using multiple sets and merge them as described in GitHub Issue #2544

register_coco_instances("my_trainsetA", {}, "train/_annotations.coco.json", "trainA")
...

cfg.DATASETS.TRAIN = ("my_trainsetA", "my_trainsetB", ... )
cfg.DATASETS.TEST = ("my_testsetA", ...)

Upvotes: 2

yogi
yogi

Reputation: 93

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

Upvotes: 2

Related Questions