Hello!
I am following the same tutorial (but using my own dataset)
Within the transforms I do a cast in order to cast the image tensors to type(torch.FloatTensor)
class ToTensor(object):
    def __call__(self, image, target):

      image = image.transpose((2, 0, 1)) 
      return torch.from_numpy(np.flip(image,axis=0).copy()).type(torch.FloatTensor), target

Nevertheless, during training:
num_epochs = 10
for epoch in range(num_epochs):
    # train for one epoch, printing every 10 iterations
    train_one_epoch(model, optimizer, train_loader, device, epoch, print_freq=10)
    # update the learning rate
    lr_scheduler.step()

I obtain the following error:
Loss is nan, stopping training
{‘loss_classifier’: tensor(2.0606, device=‘cuda:0’, grad_fn=</NllLossBackward/>), ‘loss_box_reg’: tensor(0., device=‘cuda:0’, grad_fn=</DivBackward0/>), ‘loss_objectness’: tensor(213.0078, device=‘cuda:0’,
grad_fn=</BinaryCrossEntropyWithLogitsBackward/>), ‘loss_rpn_box_reg’: tensor(nan, device=‘cuda:0’, grad_fn=</DivBackward0/>)}
An exception has occurred, use %tb to see the full traceback.
SystemExit: 1
Why is this happening?
Moreover the image visualization after the tensor cast is very poor.
Thankyou