I am trying to use COCO 2014 data for semantic segmentation training in PyTorch. I have a PSPNet model with a Cross Entropy loss function that worked perfectly on PASCAL VOC dataset from 2012. Now I am trying to use a portion of COCO pictures to do the same process. But Coco has json data instead of .png images for annotation and I somehow have to covert one to the other. I have noticed that there is annToMask in cocotools, but I cannot quiet figure out how to use that function in my case. This is kind of what my dataloader's pull item looks like
def pull_item(self, index):
I DONT KNOW WHAT TO DO HERE
raw_img = self.transform(raw_img)
anns_img = self.transform(anns_img)
return raw_img, anns_img
Below is what my training function that uses data from dataloaders looks like.
for images, labels in dataloaders_dict[phase]:
images = images.to(device)
labels = torch.squeeze(labels)
labels = labels.to(device)
with torch.set_grad_enabled(phase == 'train'):
outputs = net(images)
loss = criterion(outputs, labels.long())