clovaai / ext_portrait_segmentation

MIT License
239 stars 68 forks source link

why ignore_idx==255? in lovasz loss? #30

Closed Minotaur-CN closed 3 years ago

Minotaur-CN commented 4 years ago

Hi @HYOJINPARK @yjyoo3312

Thank you for the wonderful library! Wow! why set ignore_idx==255 in lovasz loss? which is the person label in target . Can you guide me please.....

============

main.py if train_config["loss"] == "Lovasz": from etc.lovasz_losses import lovasz_hinge criteria = lovasz_hinge(ignore=data_config["ignore_idx"]) else: from etc.Criteria import CrossEntropyLoss2d criteria = CrossEntropyLoss2d(weight,ignore=data_config["ignore_idx"]) # weight


SINet.json "data_config": { "cash" : "./pickle_file/portrait.p", "dataset_name": "CVportrait", "data_dir": "../../Link512DATA/", "classes" : 2, "ignore_idx" : 255, "num_work" : 4,

HYOJINPARK commented 4 years ago

Hello @Minotaur-CN Thanks for your asking 0 is a background 1 is a foreground. Most of the segmentation dataset denotes 255 for not labeled pixel (It means hard to classify into any class)or ignoring in training. Therefore, I just follow this custom by my habit. However, that does not need in here, cuz the dataset is 0 or 255 and 255 convert to 1

Minotaur-CN commented 4 years ago

Yes, Thanks for your quick response!

I saw normal CVDataset processing class, which using 255 as the portrait label. which label should be used for training?

Regards!


class CVDataset(torch.utils.data.Dataset): .... def getitem(self, idx): image_name = self.imList[idx] label_name = self.labelList[idx] image = cv2.imread(image_name) label = cv2.imread(label_name, 0) *label_bool = 255 ((label > 200).astype(np.uint8))**


class ToTensor(object): ... image_tensor = torch.from_numpy(image).div(255) label_tensor = torch.LongTensor(np.array(label, dtype=np.int)).div(255) #torch.from_numpy(label)