Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

About Contrastive Loss in your method #7

Open
AprilT0621 opened this issue Apr 17, 2024 · 4 comments
Open

About Contrastive Loss in your method #7

AprilT0621 opened this issue Apr 17, 2024 · 4 comments

Comments

@AprilT0621
Copy link

Hello! I am currently attempting to replicate the work presented in your paper and I am very grateful for the code you have provided. However, I have encountered an issue regarding the contrastive loss.

During my training process, the contrastive loss remains consistently at 0. After discovering this problem, I checked the inputs in the contrastive loss function (soft_image_embeds[i], anchor_image_embeds[i], soft_res_masks[i], anchor_res_masks[i]) and found that the values ​​of soft_image_embeds[i] and anchor_image_embeds[i] are almost the same, the same goes for soft_res_masks[i] and anchor_res_masks[i].
loss_contra += contra_loss(soft_image_embeds[i], anchor_image_embeds[i], soft_res_masks[i].clone().detach(), anchor_res_masks[i].clone().detach())
Here is my tensorboard visualization of the contrastive loss using the ISIC dataset and 'box' prompt, the model is ViT-b:
20240417170340

I was wondering if you could provide some insights into possible reasons for this occurrence or directions I could explore for troubleshooting? Perhaps I may have encountered some common pitfalls, but I am currently unable to ascertain them.

I look forward to your guidance and suggestions.

@zhang-haojie
Copy link
Owner

In cases with only one target in an image, the absence of negative samples in the contrast loss construction results in a constant 0 loss. We have used a method to treat the background as a special instance, and the code will be updated soon.

@lfxx
Copy link

lfxx commented Apr 23, 2024

In cases with only one target in an image, the absence of negative samples in the contrast loss construction results in a constant 0 loss. We have used a method to treat the background as a special instance, and the code will be updated soon.

looking forward to this update since i can not get 80.01 miou on ISIC,i just get 76.1.

@xmutly
Copy link

xmutly commented Jul 4, 2024

In cases with only one target in an image, the absence of negative samples in the contrast loss construction results in a constant 0 loss. We have used a method to treat the background as a special instance, and the code will be updated soon.

looking forward to this update since i can not get 80.01 miou on ISIC,i just get 76.1.

me too

@JianghaoWu
Copy link

In cases with only one target in an image, the absence of negative samples in the contrast loss construction results in a constant 0 loss. We have used a method to treat the background as a special instance, and the code will be updated soon.

looking forward to this update since i can not get 80.01 miou on ISIC,i just get 76.1.

May I ask if the result of your point as a prompt is normal? I seem to be lower than the beginning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants