SparseInst icon indicating copy to clipboard operation
SparseInst copied to clipboard

Custom dataset training: Change paths

Open kirillkoncha opened this issue 3 years ago • 12 comments

Hi!

I would like to train SparseInst model on my own dataset, which is very alike COCO dataset. However, I wonder where I can change paths to dataset, so the script would find it. Unfortunately, "Training SparseInst with Custom Datasets" section is empty. I looked through tools/train_net.py and config files, however, I did not find, where I can change paths.

Should I change paths to folders with my dataset here?

DATASETS:
  TRAIN: ("coco_2017_train",)
  TEST:  ("coco_2017_val",)

kirillkoncha avatar Sep 12 '22 17:09 kirillkoncha

@Vincent630, maybe you could help?

kirillkoncha avatar Sep 13 '22 09:09 kirillkoncha

Hi @kirillkoncha, thanks for your interest in SparseInst! As for using the custom dataset, we suggest: (1) convert the dataset format into COCO format, (2) register your own dataset,

from detectron2.data.datasets import register_coco_instances
register_coco_instances("my_dataset", {}, "json_annotation.json", "path/to/image/dir")

and then you can use your own dataset by setting the DATASETS.TRAIN or DATASETS.TEST. You can find more details in the official guide for custom dataset. Sorry for the late reply and if you have any other problems, please feel free to ask.

wondervictor avatar Sep 13 '22 15:09 wondervictor

So, I should add registration in train_net.py, change names in the config and then just run train_net.py? Or some other changes are need to be done as build_evaluator description suggests to built own evaluator for custom data...

kirillkoncha avatar Sep 16 '22 12:09 kirillkoncha

Hi @kirillkoncha, you only need to change the names in the config after you register the dataset. If you build the dataset in the coco format, there is no need to build extra evaluators.

wondervictor avatar Sep 16 '22 13:09 wondervictor

Thanks a lot for your answer! I also have one last question: when I training model on my own dataset, which have different new classes, should I use somehow already pretrained weights or train the model from scratch using the base config?

kirillkoncha avatar Sep 16 '22 14:09 kirillkoncha

@kirillkoncha, it's my pleasure. It's ok to load the COCO pre-trained weights to initialize the model with a simple modification NUM_CLASSES. Using a pre-trained model can facilitate convergence and improve the overall performance. If you have any questions, please feel free to ask~

wondervictor avatar Sep 16 '22 15:09 wondervictor

And how I can change NUM_CLASSES? I can't find this in base config, only in the training script. Or it will be done automatically based on the number of classes in dataset?

kirillkoncha avatar Sep 16 '22 19:09 kirillkoncha

Hi @kirillkoncha, the code will not automatically change the number of classes for models. You need to change the config:

MODEL.SPARSE_INST.DECODER.NUM_CLASSES

to specify the number of classes.

wondervictor avatar Sep 17 '22 04:09 wondervictor

Okay, thanks!!! But why Base-SparseInst.yaml does not have this parameter originally?

kirillkoncha avatar Sep 17 '22 14:09 kirillkoncha

Hi @kirillkoncha, it's ok to append the parameter to your config. The parameter mentioned above has been included in the config.py and has been registered.

wondervictor avatar Sep 18 '22 08:09 wondervictor

Thank you a lot! Could I ask one more question: is there any way to specifies the numbers of eight gpu's I want to use? (For example, I want to train model from 7 to 15 gpu's)

kirillkoncha avatar Sep 22 '22 22:09 kirillkoncha

Hi @kirillkoncha, it's simple, just like CUDA_VISIBLE_DEVICES=7,8,9,10,11,12,13,14,15 python train.py .....

wondervictor avatar Sep 23 '22 06:09 wondervictor

This issue will be closed, you can open a new issue if you have other problems or reopen it. Thanks for your interest in SparseInst 😊 . If you find it useful in your work or research, could you give us a star 🌟 or help us recommend SparseInst to your friends?

wondervictor avatar Oct 10 '22 03:10 wondervictor