facebookresearch / detr

End-to-End Object Detection with Transformers
Apache License 2.0
13.58k stars 2.45k forks source link

How to use early stopping or How to save best model? #438

Open ghost opened 3 years ago

ghost commented 3 years ago

Hi guys, when I trained on my custom dataset, I encountered overfitting. So I want to stop training when val_loss increases. Or Is there a way to save the model when it has the highest mAP? Has anyone ever done this?

NielsRogge commented 3 years ago

Hi,

Yes I've done this in my notebook: https://github.com/NielsRogge/Transformers-Tutorials/blob/master/DETR/Fine_tuning_DetrForObjectDetection_on_custom_dataset_(balloon).ipynb.

I use PyTorch Lightning for early stopping (they provide a callback).