Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

solution for all black mask (结果为全黑的解决方法) #250

Open
gaoming714 opened this issue Aug 24, 2023 · 2 comments
Open

solution for all black mask (结果为全黑的解决方法) #250

gaoming714 opened this issue Aug 24, 2023 · 2 comments

Comments

@gaoming714
Copy link

No description provided.

@gaoming714 gaoming714 changed the title solution for结果为全黑的解决方法 solution for all black mask (结果为全黑的解决方法) Aug 24, 2023
@gaoming714
Copy link
Author

gaoming714 commented Aug 24, 2023

file data.py
modify the saveResult function
I use cv2, because i am not familiar with io.image for output.

import cv2

def saveResult(save_path,npyfile,flag_multi_class = False,num_class = 2):
for i,item in enumerate(npyfile):
img = labelVisualize(num_class,COLOR_DICT,item) if flag_multi_class else item[:,:,0]
print(img) ## ex. [[0.16509348 0.08227982 ... 0.07113015]
img = (img > 0.5).astype(np.uint8) # .reshape(256, 256)
print(img) ## ex. [[ 0 0 0 0 ... 1 1 1 ]]
img = (img * 255)
print(img) ## ex. [[0 0 00 ... 255 255 255]]
# img = labelVisualize(num_class,COLOR_DICT,item) if flag_multi_class else item[:,:,0]
# io.imsave(os.path.join(save_path,"%d_predict.png"%i),img)
cv2.imwrite(os.path.join(save_path,"%d_predict.png"%i), img)

@Hoon-Park0618
Copy link

thx. thx. thx. thx.!!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants