tfzhou / ContrastiveSeg

ICCV2021 (Oral) - Exploring Cross-Image Pixel Contrast for Semantic Segmentation
MIT License
668 stars 88 forks source link

about the decrease of the loss #44

Open hhxzzy opened 2 years ago

hhxzzy commented 2 years ago

Hello. Thanks for your excellent work! I transplant the loss function and memory bank of your code to my own code, and run my code on Cityscapes dataset and my own dataset. But it turns out that the decrease of the contrast loss is very small. For example, the contrast loss drops from 1.27 to 1.11 after 80k epoch on Cityscapes, while the ce loss drops from 1.26 to 0.15. And the same thing happens on my own dataset. It seems that the contrast loss is not being useful during train. I wonder is it normal for the contrast loss to decrease so little? And what can I do to make full use of the contrast loss, like tuning the hyper-parameters?

guwen007 commented 2 years ago

I have the same problem too, looking forward to the author's answer

wingkeihon commented 2 years ago

@hhxzzy I'm sorry to bother you.I added the contrast loss function to my model and code, and this problem also occurred.Has your problem been solved?

hhxzzy commented 2 years ago

@hhxzzy I'm sorry to bother you.I added the contrast loss function to my model and code, and this problem also occurred.Has your problem been solved?

Hello. I try to make some change to the code, but the contrastive loss is still not going to drop much. But it seems that adding the contrastive can help improve the mIOU on Cityscapes by about 1%. Maybe it is the nature of contrastive loss that it doesn't drop much. By the way, do you use warmup_iter in your code. I found that using a warm up strategy can be helpful. The author use this strategy in his code but not metion it in the paper.

wingkeihon commented 2 years ago

已收到

tfzhou commented 2 years ago

@hhxzzy @guwen007 @wingkeihon Thanks for your interests. The contrastive loss is indeed more difficult to optimize than the CE loss. But it will still help to learn a better embedding space, which will benefit segmentation. So I will suggest to see whether the final segmentation performance is improved.

Pantherk1 commented 2 years ago

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

hhxzzy commented 2 years ago

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

If you want to run the author's scripts directly, you can take configs/cityscapes/H_48_D_4.json as an example. You need to change "data" and "loss“/"params"/"ce_weight" according to your dataset. If you wanna use contrastive loss on your own code instead of running the author's scripts, you should look at lib/loss/loss_contrast.py and lib/loss/loss_contrast_mem.py to read the implement of contrastive loss.

Pantherk1 commented 2 years ago

@tfzhou @hhxzzy @wingkeihon @guwen007 I am a novice postgraduate, and my coding ability is not high. I want to use ContrastiveSeg method on my own two-class segmentation model. Which py files should I read or what should I pay attention to? Looking forward to your answer, thank you very much.

If you want to run the author's scripts directly, you can take configs/cityscapes/H_48_D_4.json as an example. You need to change "data" and "loss“/"params"/"ce_weight" according to your dataset. If you wanna use contrastive loss on your own code instead of running the author's scripts, you should look at lib/loss/loss_contrast.py and lib/loss/loss_contrast_mem.py to read the implement of contrastive loss.

Thank you for your prompt attention.