I found the problem. I had made train_set on VOCSegmentation class rathet than myVOCSegmentation.
train_set =VOCSegmentation(PATH,year=‘2012’,download = True,image_set =‘train’,transforms=transform_train)
I corrected it and now it is working.