BiRefNet icon indicating copy to clipboard operation
BiRefNet copied to clipboard

the result from guda is different from that from cpu when testing birefnet_hr

Open AlphaCircle opened this issue 9 months ago • 6 comments

Hello, I have a curious thing after testing your new birefnet_hr. Having an image where 5 people standing in a relatively dim background, I ran your example code posted on huggingface on Google Colab T4. The resultant image shows only 4 people except the right-most person. However, I modified a little bit the sample code so as to run the same image on cpu-only (32bit float) without cuda. I got a different result where all 5 people show. This test result are same with hr or hr_matting. Is it an expected or intended result? Let me attach the mask image out of gpu and cpu in order as follows.

Image

Image

AlphaCircle avatar Mar 04 '25 05:03 AlphaCircle

Wow, that's amazing. Theoretically, FP32 / FP16 and CUDA / CPU have ~0 and 0 differences. I also did the test on many examples before. Could you provide me with the original case image? I can have a test on it.

ZhengPeng7 avatar Mar 04 '25 08:03 ZhengPeng7

Thanks for reply it. Let me just attach here. If there is any better way how you receive, please make a note here.

Image

AlphaCircle avatar Mar 05 '25 00:03 AlphaCircle

BTW, did you correctly set the resolution? I obtained similar results with BiRefNet_HR + 1024x1024. Make sure that BiRefNet_HR takes 2048x2048 inputs while BiRefNet takes 1024x1024 inputs.

ZhengPeng7 avatar Mar 05 '25 15:03 ZhengPeng7

Sure. The sample code has the transform.Compose() as you know. I just used that as it is. The first transform is (2048,2048).

AlphaCircle avatar Mar 07 '25 03:03 AlphaCircle

BTW, did you correctly set the resolution? I obtained similar results with BiRefNet_HR + 1024x1024. Make sure that BiRefNet_HR takes 2048x2048 inputs while BiRefNet_HR takes 1024x1024 inputs.

I'm assuming you meant BiRefNet takes 1024x1024 rather than _HR

timwillhack avatar Jul 12 '25 14:07 timwillhack

Yeah, my mistake on that typo. I've fixed it.

ZhengPeng7 avatar Jul 12 '25 16:07 ZhengPeng7