kaixin96 / PANet

Code for our ICCV 2019 paper PANet: Few-Shot Image Semantic Segmentation with Prototype Alignment
320 stars 64 forks source link

Problems about visualizing the pred output #18

Closed TimandXiyu closed 4 years ago

TimandXiyu commented 4 years ago

Hi, thanks for the source code, it really helps me on my on-going project.

Can you give me some hints about how to visualize the prediction from the network? The results in the paper looks good but I am also interested in what package is used to visualize the output?

I was using Tensorboard to visualize the the input images and masks, and it works fine. But for prediction made by the network, I had little to no clue if I should do some post-processing or not even if the paper said no post-processing and decoding is needed. The output looks like some heatmap under greyscale. (not black and white mask-like stuff)

BTW, the training loss curve looks exactly like the paper said and the test result is also close to the paper's results.

WujiangXu commented 4 years ago

Hi, thanks for the source code, it really helps me on my on-going project.

Can you give me some hints about how to visualize the prediction from the network? The results in the paper looks good but I am also interested in what package is used to visualize the output?

I was using Tensorboard to visualize the the input images and masks, and it works fine. But for prediction made by the network, I had little to no clue if I should do some post-processing or not even if the paper said no post-processing and decoding is needed. The output looks like some heatmap under greyscale. (not black and white mask-like stuff)

BTW, the training loss curve looks exactly like the paper said and the test result is also close to the paper's results.

hello,I have met the same problem.Did you solve this problem?This output shape is like[1,2,417,417],I don't know how to deal it.

TimandXiyu commented 4 years ago

Hi, thanks for the source code, it really helps me on my on-going project. Can you give me some hints about how to visualize the prediction from the network? The results in the paper looks good but I am also interested in what package is used to visualize the output? I was using Tensorboard to visualize the the input images and masks, and it works fine. But for prediction made by the network, I had little to no clue if I should do some post-processing or not even if the paper said no post-processing and decoding is needed. The output looks like some heatmap under greyscale. (not black and white mask-like stuff) BTW, the training loss curve looks exactly like the paper said and the test result is also close to the paper's results.

hello,I have met the same problem.Did you solve this problem?This output shape is like[1,2,417,417],I don't know how to deal it.

Hi, I had solved it. Please pay attention to one line of code using argmax in test.py, it is actually extracting the predicted mask. Those two channels are the distance to background and foreground. You need to use argmax to determine if the pixel is belong to background or foreground. code like: argmax(pred[0]) would give you want you want.

wllpx commented 4 years ago

Hello, I dont't know how to visualize the prediction, can you prompt me?

TimandXiyu commented 4 years ago

Hello, I dont't know how to visualize the prediction, can you prompt me?

See line 125 of test.py, and think again why it uses argmax to determine whether the pixel should be black or white. I had already explained it above.

gaowq2017 commented 4 years ago

Hi@TimandXiyu, I meet some questions when visualize the prediction as follow: The version of cv2=4.2; My code in here

visual

            mean = [0.485, 0.456, 0.406]
            std = [0.229, 0.224, 0.225]
            pred = np.array(query_pred.argmax(dim=1)[0].cpu())
            q_img = query_images[0].cpu()[0]
            qu_img = np.array(torch.transpose(q_img, 0, 2))
            que_img = qu_img * std + mean
            que_img = que_img.reshape(512, 512, 3)
            My_mask = np.where(pred > 0, 255, 0)
            My_mask = My_mask.reshape(512, 512).astype(np.uint8)
            contours, hierarchy = cv2.findContours(My_mask, cv2.RETR_TREE, cv2.CHAIN_APPROX_SIMPLE)
            cv2.drawContours(que_img, contours, -1, (0, 255, 0), 1)
            plt.imshow(que_img)
            plt.show()

I want draw the contours in querry image, but the error in line :contours, hierarchy =cv2.findContours(My_mask, cv2.RETR_TREE,cv2.CHAIN_APPROX_SIMPLE) as follow: TypeError: Expected Ptr for argument 'image' I can't find the root source of error ! Thanks!

TimandXiyu commented 4 years ago

I am not familiar with openCV so it would not be possible for me to further understand your code about using cv2 APIs and those potential bugs. Sorry, I really have no idea.

Maybe you should first ensure that you can have a correct binary predicted mask before going to plot the contour (plot it out to make sure). I also suggest viewing openCV's documentation for further suggestions about the shape and data type of input.

If your input shape and type perfectly satisfied those requirements, you should ask those developer directly...

gaowq2017 commented 4 years ago

Hi @TimandXiyu , I have resolved it by the moduel of color_map. Thank you very much!

fewshotstudy commented 7 months ago

Hi @TimandXiyu , I have resolved it by the moduel of color_map. Thank you very much!

Hello,Sir. when i run test.py,i meet same question. I wanna visualize the predition results, how can i get the visual result? Can you share some details? Thx