Can any one help me about this error

Epoch 0/24

ValueError Traceback (most recent call last)
~\AppData\Local\Temp/ipykernel_17472/ in
----> 1 model = train_model(model, criterion, optimizer_ft, exp_lr_scheduler,num_epochs=25)

~\AppData\Local\Temp/ipykernel_17472/ in train_model(model, criterion, optimizer, scheduler, num_epochs)
30 # track history if only in train
31 with torch.set_grad_enabled(phase == ‘train’):
—> 32 result = model(inputs)
33 _, preds = torch.max(outputs, 0)
34 loss = criterion(outputs, labels)

C:\ProgramData\Anaconda3\lib\site-packages\torch\nn\modules\ in _call_impl(self, *input, **kwargs)
1100 if not (self._backward_hooks or self._forward_hooks or self._forward_pre_hooks or _global_backward_hooks
1101 or _global_forward_hooks or _global_forward_pre_hooks):
→ 1102 return forward_call(*input, **kwargs)
1103 # Do not call functions when jit is used
1104 full_backward_hooks, non_full_backward_hooks = [], []

C:\ProgramData\Anaconda3\lib\site-packages\torchvision\models\detection\ in forward(self, images, targets)
55 “”"
56 if and targets is None:
—> 57 raise ValueError(“In training mode, targets should be passed”)
58 if
59 assert targets is not None

ValueError: In training mode, targets should be passed

Here is the link to the source code for the GeneralizedRCNN.

If you go down to line 60, you will see that when in training mode you need to pass not only the image, but also the targets.

From the error that you have posted, it seems you are only passing the variable inputs forward. If this variable has the images and targets, then you should separate them into two vars.

Here is a tutorial example with FasterRCNN, where they also pass the targets in training, but not in evaluation mode.

Hope this helps.