动态UNet

使用 PixelShuffle ICNR 上采样的 Unet 模型,可构建在任何预训练架构之上

来源

Unet块

 UnetBlock (up_in_c, x_in_c, hook, final_div=True, blur=False,
            act_cls=<class 'torch.nn.modules.activation.ReLU'>,
            self_attention=False, init=<function kaiming_normal_>,
            norm_type=None, ks=3, stride=1, padding=None, bias=None,
            ndim=2, bn_1st=True, transpose=False, xtra=None,
            bias_std=0.01, dilation:Union[int,Tuple[int,int]]=1,
            groups:int=1, padding_mode:str='zeros', device=None,
            dtype=None)

一个准 UNet 块,使用 PixelShuffle_ICNR 上采样


来源

ResizeToOrig

 ResizeToOrig (mode='nearest')

将快捷连接与模块结果合并:如果 dense=True 则连接,否则相加。


来源

DynamicUnet

 DynamicUnet (encoder, n_out, img_size, blur=False, blur_final=True,
              self_attention=False, y_range=None, last_cross=True,
              bottle=False, act_cls=<class
              'torch.nn.modules.activation.ReLU'>, init=<function
              kaiming_normal_>, norm_type=None, **kwargs)

从给定架构创建一个 U-Net。

from fastai.vision.models import resnet34
m = resnet34()
m = nn.Sequential(*list(m.children())[:-2])
tst = DynamicUnet(m, 5, (128,128), norm_type=None)
x = cast(torch.randn(2, 3, 128, 128), TensorImage)
y = tst(x)
test_eq(y.shape, [2, 5, 128, 128])
tst = DynamicUnet(m, 5, (128,128), norm_type=None)
x = torch.randn(2, 3, 127, 128)
y = tst(x)