openseg-group / OCNet.pytorch

Please choose the openseg.pytorch project for the updated code that achieve SOTA on 6 benchmarks!
MIT License
812 stars 128 forks source link

inference bug #26

Closed unique-null closed 5 years ago

unique-null commented 6 years ago

Hi PkuRainBow, There is a bug in generate_submit.py, where only scale >1 will resize the input image and, as a result, the 0.75 scale will not be activated.


    """
         Predict the whole image w/o using multiple crops.
         The scale specify whether rescale the input image before predicting the results.
    """
    N_, C_, H_, W_ = image.shape

    if torch_ver == '0.4':
        interp = nn.Upsample(size=(H_, W_), mode='bilinear', align_corners=True)
    else:
        interp = nn.Upsample(size=(H_, W_), mode='bilinear')

    if scale > 1:
        scaled_img = ndimage.zoom(image, (1.0, 1.0, scale, scale), order=1, prefilter=False)
    else:
        scaled_img = image```
PkuRainBow commented 6 years ago

So..... Do you mean I only employ two scales for test set?......

So sad.........

unique-null commented 6 years ago

Yes, I have debug it. The shape of the output features before upsampling, are the same for scale 0.75 and 1.0. By the way, have you test on more scales, such as 0.5 0.75 1.25 1.5 1.75 2.0 .

PkuRainBow commented 6 years ago

I think more scales can improve the performance..... I just try some scales to save the time.

It takes much more time if you test with too many scales.

unique-null commented 6 years ago

Yes, I found that the test method is do time consuming, especially, the sliding testing. Therefore, for scale > 1, I adopt full input for testing, then resize the output to 1024,2048. It may consume more GPU memory, but significantly reduce the testing time and performance keeps similar.

PkuRainBow commented 6 years ago

@SwagJzzZ I do not employ the sliding method, which is too slow.

unique-null commented 6 years ago

@PkuRainBow you mean that all the scale, you adopt the function predict_whole_img ?

PkuRainBow commented 6 years ago

Yes. But it seems the memory is not enough for larger scale such as 1.75x and 2x.

PkuRainBow commented 5 years ago

@PkuRainBow you mean that all the scale, you adopt the function predict_whole_img ?

@SwagJzzZ

I employ sliding method for scale larger than 1x as the memory problem.

Besides, we only need to slide 4 times instead of sharing too many common parts as the PSPNet.

For example, if you test the image of 2048x4096, then you only need to predict four crops of 1024x2048 is Ok.

However, more scales for testing is really time consuming. For example, if I choose three scales for testing on the test set, it can take about ~10 hours. If more scales are used, much more time is needed.

Only if you have enough resources, the multiscale testing is really heavy.

PkuRainBow commented 5 years ago

@SwagJzzZ Currently, we could achieve 81.54 on the testing set of CS by fixing the multi-scale bugs.

And we will keep improving this number in the recent week.

unique-null commented 5 years ago

@PkuRainBow Congratulations! What scales did you adopt?

PkuRainBow commented 5 years ago

@SwagJzzZ The original scales [0.75x, 1x, 1.25x] is OK.

unique-null commented 5 years ago

@PkuRainBow Thanks for your reply. I am trying to train the model on VOC2012.

PkuRainBow commented 5 years ago

@SwagJzzZ Great!

We plan to add the experiments on VOC2012 in the futher month.

It would be great if you could share your results with us in advance.