zhixuhao / unet

unet for image segmentation
MIT License
4.6k stars 2k forks source link

cannot write mode F as PNG #252

Open judycpChen opened 11 months ago

judycpChen commented 11 months ago

微信图片_20231225110818 微信图片_20231225110825 I ran into this problem when I was running main.py. How do I fix it

angleboy8 commented 10 months ago

网上说应该将输出图像转成整数,bug是没了,但是结果显示的不对。

zadorliza commented 8 months ago

I have the same problem, not sure how to solve it. Did you solve it? UPD: as I understood, this error means that program try to save an array to PNG. I found location of this error: file data.py, function saveResult. Object 'img' in this function is ndarray, and I don't know yet how to convert it to PNG file.

UPD2: I still don't know why I get this error because io.imsave must work with numpy arrays. But I found a way to get an images anyway: instead of "io.imsave(os.path.join(save_path,"%d_predict.png"%i),img)" you can write this: image Not perfect solution because if you have a lot of test images, it will take a lot of time to save it by yourself. Besides, saved images have axis, like this one: Figure_1

partha-90 commented 4 months ago

find and change in saveResult (data.py) for grayscale image

img = labelVisualize(num_class,COLOR_DICT,item) if flag_multi_class else (item[:,:,0]*255).astype(np.uint8)