lukemelas / deep-spectral-segmentation

[CVPR 2022] Deep Spectral Methods: A Surprisingly Strong Baseline for Unsupervised Semantic Segmentation and Localization
229 stars 41 forks source link

CRF up-sampled images are blank #20

Closed SMSD75 closed 1 year ago

SMSD75 commented 1 year ago

Hi,

I am exactly following the steps mentioned for object segmentation. I can see the segmentations in the folder "patch". However, when I up sample them using CRF, everything becomes a big black picture. Do you know what might be wrong?

lukemelas commented 1 year ago

Hmm, that is strange. Have you checked that crf function works, so that you know it's not an installation error or something having to do with SimpleCRF?

SMSD75 commented 1 year ago

Thank you for your reply. I figured out the reason for the mismatch. The saved images in the folder CRF are ok; the problem with black image was because of the scales of the number; However, I am getting a pretty low number for DINO-s16 on CUB. It is only 30% for MIOU. In fact, the reason that I thought the CRF images were not ok was the low score for DINO-s16. The difference between what I got compared to the paper is about 46%, and I am confused about whether I did something wrong or not. I can send you the extracted patches, features, or CRF images to evaluate them with the GT yourself.

lukemelas commented 1 year ago

Glad to hear the CRF is working correctly.

Hmm, the score should definitely be higher. When you look at the images, do they look correct? For CUB it should almost always get the bird. Sometimes it also get the branch or misses out on some of the fine details.

SMSD75 commented 1 year ago

As far as I see, the patches are ok, although, because the size of the images is very different from the DINO's spatial resolution, when resizing some of them, they become inaccurate. To me, this makes sense since in _extract_crf_segmentations the following code exists:

# Sizes P = downsample_factor H, W = image.shape[:2] H_patch, W_patch = H // P, W // P H_pad, W_pad = H_patch * P, W_patch * P
`

Resize and expand

segmap_upscaled = cv2.resize(segmap, dsize=(W_pad, H_pad), interpolation=cv2.INTER_NEAREST)  # (H_pad, W_pad)
segmap_orig_res = cv2.resize(segmap, dsize=(W, H), interpolation=cv2.INTER_NEAREST)  # (H, W)
segmap_orig_res[:H_pad, :W_pad] = segmap_upscaled  # replace with the correctly upscaled version, just in case they are different

` , which somehow merges the upscaled images from different approaches to be sure that everything is covered. This might increase accuracy but reduce MIOU. For instance, I get 80% ACC.

SMSD75 commented 1 year ago

Thank you for your kind answering. I solved the issue. The file names in the images.txt and the directory in which the images existed were not aligned. After sorting the names, I reproduced the results.