Lydorn / Polygonization-by-Frame-Field-Learning

This repository contains the code for our fast polygonal building extraction from overhead images pipeline.
BSD 3-Clause "New" or "Revised" License
288 stars 70 forks source link

question about weighted loss #11

Closed wangyi111 closed 3 years ago

wangyi111 commented 3 years ago

Hi, i saw your paper and got something unclear: when you did the edge segmentation task, were you using dice loss + weighted cross entropy (2 classes: edge and background)? For the weighted BCE, were you using the pixel frequency of each class as the weights?

Lydorn commented 3 years ago

Hi wangyi111,

There are 2 building classes in total: interior and edge. They are inclusive so that an edge pixel can also be an interior pixel. They both have their corresponding background class. For the weighted BCE, the pixel frequency of classes is indeed used for the weights. However there is more to it: the distance to the 2 closest buildings affect the weights (as in the original U-Net paper) as well as the size of the building a pixel belongs to (as in the Open Solution to the CrowdAI Challenge https://github.com/neptune-ai/open-solution-mapping-challenge). See the compute_seg_loss_weigths() function for the details: https://github.com/Lydorn/Polygonization-by-Frame-Field-Learning/blob/b551af305c1934ecf170907058741f033d123dc6/frame_field_learning/losses.py#L147

I hope this helps!

wangyi111 commented 3 years ago

understand now, thank you!