ZhengPeng7 / BiRefNet

[CAAI AIR'24] Bilateral Reference for High-Resolution Dichotomous Image Segmentation
https://www.birefnet.top
MIT License
1.25k stars 98 forks source link

boundary loss #112

Open minushuang opened 1 week ago

minushuang commented 1 week ago

Hi, I find the ContourLoss weight value is 0 in both the matting and segment task. can I set it to a positive value to strength the learning process for the edges when training the matting task or segment?

ZhengPeng7 commented 1 week ago

Of course, but I'm not sure about its performance on your tasks. It didn't bring improvement on the DIS task I did.

minushuang commented 1 week ago

ok thank u, I will have a try.

and an other question about the grad_map loss, I noticed that in the code, BCE loss is used for calculating gradient loss in default.

If I am training for matting, would it be better to use MSE instead?

the source code intrain.py is

if config.out_ref:
    self.criterion_gdt = nn.BCELoss() if not config.use_fp16 else nn.BCEWithLogitsLoss()

for matting, may change to

if config.out_ref:
    self.criterion_gdt = nn.MSELoss() #config.use_fp16=False

I'm not sure if this is better, please could you provide some advice?

ZhengPeng7 commented 1 week ago

Sure, it makes sense. You can try it. I am very glad to hear from you about the results!