ContrastiveSeg
ContrastiveSeg copied to clipboard
About the hard anchor samping
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!
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.
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
@tfzhou Does the proposed solution from @q671383789 answers the question? Thanks a lot for your great work!