当前位置:网站首页>Bilinear upsampling and f.upsample in pytorch_ bilinear

Bilinear upsampling and f.upsample in pytorch_ bilinear

2022-07-01 03:30:00 It's seventh uncle

stay Fully Convolutional Networks for Semantic Segmentation In this article , Introduction to Bilinear Upsampling This upsampling method , Although the article ends with deconvolution, The reason given is that you don't want upsampling filter Is constant = =!
Because it used to be upsampling The way is very simple , For example, zoom in twice , It is to copy one pixel into four . This will cause the image to become blurred .

linear interpolation

Before introducing bilinear interpolation , First, let's introduce linear interpolation .
 Insert picture description here
In fact, to put it bluntly, it's very simple , That is, two points determine a line , Then I know on this line x, Naturally y. alike , It is known that y Words , Naturally, it can also be deduced that x.

Bilinear interpolation

In the image , We often face two dimensions , Even three-dimensional ( contain channel) Image , that , It's going on upsampling When we use bilinear interpolation and trilinear interpolation .
So called bilinear interpolation , The principle is the same as linear interpolation , And it is also realized by using cubic linear interpolation . Look at the picture first .
 Insert picture description here
 Insert picture description here

The effect of bilinear interpolation

Reference blog : The principle of quadratic linear interpolation + Code details 【python】
Double line interpolation algorithm is a better image scaling algorithm , It makes full use of the four real pixel values around the virtual points in the source image to jointly determine a pixel value in the target image , Therefore, the scaling effect is much better than simple nearest neighbor interpolation . because Image bilinear interpolation will only use adjacent 4 A little bit , Therefore, the denominator of the following formula is 1.
 Insert picture description here
 Insert picture description here

F.upsample_bilinear

If in pytorch Used in the project of F.upsample_bilinear function , The following warning will appear ( Indicates that this function is obsolete , Recommended nn.functional.interpolate Instead of )

UserWarning: nn.functional.upsample_bilinear is deprecated. Use nn.functional.interpolate instead.
  warnings.warn("nn.functional.upsample_bilinear is deprecated. Use nn.functional.interpolate instead.")
原网站

版权声明
本文为[It's seventh uncle]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/182/202207010315157536.html