dvlab-research/PFENet

Where can I view the segmentation results of images

Thanatos7724 opened this issue · 3 comments

Where can I view the segmentation results of images

I solved.
Note the tensor dimension. Need to add a dimension of your own, and transform tensor to PIL

I solved. Note the tensor dimension. Need to add a dimension of your own, and transform tensor to PIL

I'm sorry to bother you, can you teach me how to view the inputs and segmentation result? I will appreciate if you share the code with me. Thank you.

I solved. Note the tensor dimension. Need to add a dimension of your own, and transform tensor to PIL

I'm sorry to bother you, can you teach me how to view the inputs and segmentation result? I will appreciate if you share the code with me. Thank you.

Sorry, I only recently noticed your question.
add the following code after ''output = output.max(1)[1]'' in test.py
you should add new global variables :savepath in test.py

output_squ = output_squ.cpu().numpy() # 将tensor数据转为numpy数据
maxValue = output_squ.max()
output_squ = output_squ * 255 / maxValue # normalize,将图像数据扩展到[0,255]
mat = np.uint8(output_squ) # float32-->uint8
mat = mat.transpose(1, 2, 0) # mat_shape: (982, 814,3)
save_path = os.path.join(savepath, "picnum{}.png".format(i))
cv2.imwrite('{}'.format(save_path), mat)

predicted mask can save to the folder which path is "savepath" , the predicted mask named picnum0,1,2...

suggest you to add the following code after : "def getitem(self, index): image_path, label_path = self.data_list[index]" in dataset.py

f2 = open("文件路径.txt", 'a', encoding='UTF-8')
f2.write(image_path)
f2.write('\n')
f2.close()

to match the predicted mask and the query image