pytorch/vision

[models] Suggestion of GeneralizedRCNN forward output

Open

#1,775 建立於 2020年1月19日

在 GitHub 查看
 (9 留言) (4 反應) (0 負責人)Python (6,858 fork)batch import
enhancementhelp wantedmodule: modelstopic: object detection

倉庫指標

Star
 (15,050 star)
PR 合併指標
 (平均合併 12天 8小時) (30 天內合併 14 個 PR)

描述

🚀 Loss computation in eval mode

Even in eval mode, if the user passes targets to the forward method, return (or store) the loss dictionary in addition to the detections.

Motivation

Recently, I made a quick training script for MaskRCNN on a different dataset. And since I usually look at training and validation loss evolution over epochs to spot potential overfit, I checked how I could get around the current forward method of GeneralizedRCNN.

In train mode, it returns only the loss dictionary (which is fined, there is little use to check detections). Now, say in eval mode that I want to get the loss. There is no way to retrieve it currently.

Pitch

Change the forward method implementations of RoiHeads, RegionProposalNetwork and GeneralizedRCNN so that when both an input and a target are passed to GeneralizedRCNN.forward it returns both the loss dictionary and the detections.

Instead of checking self.training, we could check self.training or targets is not None

Happy to come up with a PR if you think that's a good idea, cheers!

貢獻者指南