TypeError: __call__() takes 2 positional arguments but 3 were given. To train Raccoon prediction model using FastRCNN through Transfer Learning
 from torchvision.models.detection.faster_rcnn import FastRCNNPredictor
 from engine import train_one_epoch, evaluate
 import utils
 import torchvision.transforms as T

 num_epochs = 10
 for epoch in range(num_epochs):
    train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)
    lr_scheduler.step()
    evaluate(model, data_loader_test, device=device)


I am using the same code as provided in this link Building Raccoon Model but mine is not working. 

This is the error message I am getting
TypeError                                 Traceback (most recent call last)
 in ()

  2 for epoch in range(num_epochs):

  3    # train for one epoch, printing every 10 iterations

  4   ----&gt; train_one_epoch(model, optimizer, data_loader, device, epoch, print_freq=10)

  5     # update the learning rate

  6   lr_scheduler.step()


7 frames

 in getitem(self, idx)

 29         target["iscrowd"] = iscrowd

 30         if self.transforms is not None:

 31        ---&gt; img, target = self.transforms(img, target)

 32         return img, target
 33 


TypeError: call() takes 2 positional arguments but 3 were given

The above answer is incorrect, I accidentally upvoted before noticing. You are using the wrong Compose, note that it says
https://pytorch.org/tutorials/intermediate/torchvision_tutorial.html#putting-everything-together
&quot;In references/detection/, we have a number of helper functions to simplify training and evaluating detection models. Here, we will use references/detection/engine.py, references/detection/utils.py and references/detection/transforms.py. Just copy them to your folder and use them here.&quot;
there are helper scripts. They subclass the compose and flip methods
https://github.com/pytorch/vision/blob/6315358dd06e3a2bcbe9c1e8cdaa10898ac2b308/references/detection/transforms.py#L17
I did the same thing before noticing this. Do not use the compose method from torchvision.transforms, or else you will get the error above. Download their module and load it.
