xwjabc / hed

A PyTorch reimplementation of Holistically-Nested Edge Detection
169 stars 42 forks source link

A strange phenomenon #60

Open Billy-ZTB opened 5 months ago

Billy-ZTB commented 5 months ago

Hello! Thanks for your providing the code, I discovered a strange thing while I was using this repo to do boundary detection. It was something about the label images. My label images was generated from semantic segmentation labels by discovering boundaries of different objects. Things went well when I use boundary labels generated by canny operation in cv2, but when I used seg2edge function in matlab to generate boundary with radius=2(to get thicker boundary), the loss didn't decrease and the model couldn't learn boundary information. The loss function I was using is weighted_cross_entropy_loss in this repo. I have no idea how the boundary's thickness would influence the training process, could you please provide your opinion?

Using edge from canny: canny image It can be seen that the loss is decreasing gradually.

Using thicker boundary: radius=2 image batch-109-1st-image Loss wouldn't decrease, it goes 4 times bigger than that in epoch1 after several epochs. Both two types of boundaries are binary boundary(edge pixels=1, non-edge=0). I was using pretrained parameters 'hed_pretrained_bsds.py36pickle'.

I am new in this field and I am not familiar with the mechanism of binary cross entropy loss. Could you please give me some hint? Looking forward to your reply! 😊