How to train the fasterrcnn_resnet50_fpn in torchvision

Hello all.
I am importing the model as frcnn = fasterrcnn_resnet50_fpn(pretrained=False, num_classes=6, pretrained_backbone=True, progress=True)

In the docs it is written that I have to pass a list of images and targets which would return the cls_loss and regression_loss,
I am sorry this might be a silly question, but we have to propagate the loss backward, or is the loss.backward() or optim.step() taken care of internally?

TIA

The Object Detection Finetuning Tutorial might be a good starter for your use case.
In this tutorial the train_one_epoch utility function is used, which takes care of the backward and update step.
However, you could of course look at the linked source code and apply these steps manually.

1 Like