Hi, I am trying to practice semantic segmentation using Pascal Voc. I wrote a subclass of VOCSegmentation, and I defined transformation. When I try to read one element of train_set, I got the following error,
call() takes 1 positional argument but 3 were given
I can’t understand where the problem is. Here is my code:
class myVOCSegmentation(VOCSegmentation):
def __getitem__(self,index):
img = Image.open(self.images[index].convert('RGB'))
target = Image.open(self.masks[index])
if self.transforms is not None:
agumented = self.transforms(image= np.array(img),mask = np.array(target))
img = agumented['image']
target = agumented['mask']
# here we have 20 classes, so we set data larger than 20 equal to 0
target[target>20]=0
img = to_tensor(img)
target = torch.from_numpy(target).type(torch.long)
return(img,target)
h,w = 520,520
mean = [0.485, 0.456, 0.406]
std = [0.229, 0.224, 0.225]
transform_train = Compose([Resize(h,w),
HorizontalFlip(p=0.5),
Normalize(mean=mean,std=std)])
transform_val = Compose([Resize(h,w),Normalize(mean=mean,std=std)])
PATH = ‘./data’
train_set =VOCSegmentation(PATH,year=‘2012’,download = True,image_set =‘train’,transforms=transform_train)
val_set = VOCSegmentation(PATH,year=‘2012’,download = True,image_set =‘val’,transforms=transform_val)
for item in train_set:
print(item)
break
call() takes 1 positional argument but 3 were given