facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
29.32k stars 7.32k forks source link

DefaultTrainer with LazyConfigs #5176

Open carandraug opened 6 months ago

carandraug commented 6 months ago

šŸš€ Feature

Enable use of LazyConfigs with the existing Defaultrainer

Motivation & Examples

DefaultTrainer is quite nice. Straight from the documentation "it includes more standard default behaviors that one might want to opt in, including default configurations for optimizer, learning rate schedule, logging, evaluation, checkpointing etc.". However, it is limited to yacs configs.

If one is using the new lazyconfigs, the advice is to copy paste the code in lazyconfig_train_net.py and start hacking at it, which can be a bit daunting. I think it would make things simpler if one could just use DefaultTrainer to begin with and then expand as needed. Effectively the same approach one would take with YACS configs.

Suppose that DefaultTrainer did not exist. The advice for someone with a YACS config would then be to copy a tools/train_net.py (a much more complicated one - the current one effectively calls DefaultTrainer) and start from there. Having DefaulTrainer simplifies this. Unfortunately, this option does not exist if one is starting with lazyConfig files.

Having had a look at it, I feel that it should be possible (a lot of the code in DefaultTrainer is similar to the code in lazyconfig_train_net.py). There's a few cases that I'm unsure about but if I know that there is interest by upstream, then I could spend time working on it.

Please let me know if there's interest on extending DefaultTrainer to support LazyConfig.

hiyyg commented 6 months ago

That would be very great.