pytorch / pytorch/vision

[models] Suggestion of GeneralizedRCNN forward output

Open
#1,775 9 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement help wanted module: models topic: object detection
Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🚀 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!

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at GeneralizedRCNN.forward and trace how it calls RoiHeads and RegionProposalNetwork.forward. Determine the behavior when targets are supplied in eval mode, including whether losses are returned or stored. Done means eval mode can expose both the loss dictionary and detections for that case, with coverage for the changed behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
computer-vision, machine-learning
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.