1

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

yogi
  • 73
  • 1
  • 12

2 Answers2

2

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
DV82XL
  • 5,350
  • 5
  • 30
  • 59
yogi
  • 73
  • 1
  • 12
  • Did you end up using `coco-assistant`? Did it solve your multi-dataset issue? – DV82XL Dec 01 '21 at 05:41
  • Do you need to disclose any affiliation with the creator of that? – Yunnosch Dec 01 '21 at 06:11
  • 1
    @DV82XL Yes I ended up using coco-assistant. It solved my multiple dataset issue – yogi Dec 22 '21 at 14:56
  • @Yunnosch, As coco-assistant is made opensource. I did not have any problem with creator. You can always contact the creator for your specific issues if you have – yogi Dec 22 '21 at 14:58
2

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", ...)
  • Just learning to do this for the first time, came across this. I guess what you mean by the ellipses is that you can have a second line like `register_coco_instances("my_trainsetB", {}, "train/_annotations.coco.json", "trainB")` Might be a bit clearer to newbies if that line was explicitly there. Thanks! – MaanDoabeDa Feb 27 '23 at 14:01