HRNet-Semantic-Segmentation icon indicating copy to clipboard operation
HRNet-Semantic-Segmentation copied to clipboard

Input and output size difference

Open bluesky314 opened this issue 4 years ago • 4 comments

I am inputting 512512 image but getting out 128128 with cityscapes/seg_hrnet_w18_small_v2_512x1024_sgd_lr1e-2_wd5e-4_bs_12_epoch484.yaml. Am i doing something wrong? I just load the config file in the model. How to get full-resolution?

bluesky314 avatar Mar 19 '20 17:03 bluesky314

Our model outputs 1/4 resolution predictions and the process of upsampling to full-resolution is not included in the model.

You can add bilinear upsampling after our model. https://github.com/HRNet/HRNet-Semantic-Segmentation/blob/8e4c0c3076ff319dcc8354a971b29c1250c16b1d/lib/datasets/cityscapes.py#L169

sunke123 avatar Mar 30 '20 04:03 sunke123

Our model outputs 1/4 resolution predictions and the process of upsampling to full-resolution is not included in the model.

@sunke123 Is it possible to make outputs 1/2 or 1/1 withouth resample.

The next code works well for resample:

F.interpolate(out, size=(ori_height, ori_width),
                        mode='bilinear', align_corners=self.align_corners)

However, if you are working with high res images. Resampling from 250 up to 1000 produces bad results.

WaterKnight1998 avatar Apr 29 '20 11:04 WaterKnight1998

Putting 2 deconvolution at the end of the model would also solve your problem without using interpolation in this setup:

self.final_deconv = nn.ConvTranspose2d(config.DATASET.NUM_CLASSES, config.DATASET.NUM_CLASSES, kernel_size=4, stride=2, padding=1)

You need to add it in lib/models/seg_hrnet.py in HighResolutionNet init function. Then put 2 of it at the end of forward function and then return x:

x = self.final_deconv(x)
x = self.final_deconv(x)

hamzagorgulu avatar Oct 26 '23 12:10 hamzagorgulu

unsubscribe

At 2023-10-26 21:00:00, "hamzagorgulu" @.***> wrote:

Putting 2 deconvolution at the end of the model would also solve your problem without using interpolation in this setup:

self.final_deconv = nn.ConvTranspose2d(config.DATASET.NUM_CLASSES, config.DATASET.NUM_CLASSES, kernel_size=4, stride=2, padding=1)

You need to add it in lib/models/seg_hrnet.py in HighResolutionNet init function. Then put 2 of it at the end of forward function and then return x:

x = self.final_deconv(x) x = self.final_deconv(x)

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

mengkai-liu avatar Nov 20 '23 13:11 mengkai-liu