plemeri / InSPyReNet

Official PyTorch implementation of Revisiting Image Pyramid Structure for High Resolution Salient Object Detection (ACCV 2022)
MIT License
321 stars 61 forks source link

Image mask alignment problem #39

Closed babyta closed 8 months ago

babyta commented 8 months ago

Hello author, for a recent test, I wrote an inference script myself, but the inference results between threshold value 512 and None seem to be 1-2 pixels different.

babyta commented 8 months ago

512 The picture above shows the result of threshold 512 None The picture above shows the result of threshold None Please ignore the quality of the mask images itself,focusing on the edges of the two images, you can see that they are not aligned

xkaple00 commented 8 months ago

I also noticed such behavior. In my experiments if I do inference on images larger than 512 px with --threshold parameter = 512, the produced mask is shifted a few pixels up and left in comparison with --threshold=None

plemeri commented 8 months ago

Hi @babyta and @xkaple00, if threshold is specified, images with shorter side length (either width or height) below the threshold value will not deploy pyramid blending. On the other hand, if threshold value is not specified (None), then it will not deploy pyramid blending what so ever.

Also, because pyramid blending is a post-processing method combining LR and HR predictions into single mask, there could be some drawbacks like 1~2 pixel shift.

Please notice that pyramid blending will produce meaningful results only when the given image is high resolution, because pyramid blending is proposed to produce high resolution prediction when without high resolution dataset available. It is obvious when high resolution dataset is available, we definitely need to use them for high quality prediction. One of our contributions was, even without costly high resolution dataset, we were able to generate competitive high quality saliency map with pyramid blending technique.

Also, if you want to use our method in real-world scenario, please use Plus_Ultra configuration, or our python API / cli tool transparent-background.

Lastly, if you have an idea to solve the problem, please contact me or you can create a pull request. Thank you for letting me know such problem. 😄

babyta commented 8 months ago

Thank you for your reply, your sharing is very useful!