ContrastiveSeg icon indicating copy to clipboard operation
ContrastiveSeg copied to clipboard

About the hard anchor samping

Open leeh43 opened this issue 2 years ago • 3 comments

Hi, thank you for the great work. I am currently using your pipeline on my dataset. I have a question about the hard anchor sampling function. As the label (128 x 128) is resampled to the feature size (16 x 16), the segmentation prediction from the model is not resampled and it pops up an error of different dimensions between labels and predictions in the following line:

hard_indices = ((this_y_hat == cls_id) & (this_y != cls_id)).nonzero()

Is there anything that I can do to fix the error?

Thank you so much!

leeh43 avatar Feb 26 '22 06:02 leeh43

I met the same problem before. I think this may because the stride of your backbone network is different from the author's. You can try resizing the labels, features and predictions to the same size to see if it works.

hhxzzy avatar Mar 01 '22 06:03 hhxzzy

I met the problem, and It's because ur decoder have already upsample the predictions, like after the encoder maybe the feature_map's h w is 16X16 , so the embed is bsXembed_dimX16X16, but if your decoder upsample the feature_map maybe ur prediction is like 128X128, this would report an error. the solution is resize your prediction to the same size as the embed like the way to do with labels

wcyjerry avatar Mar 07 '22 15:03 wcyjerry

@tfzhou Does the proposed solution from @q671383789 answers the question? Thanks a lot for your great work!

lennart-maack avatar Oct 28 '22 17:10 lennart-maack