模块更新于 2026-11-21· 浏览 5· 下载 0
MKDC MK-UNet 模块
结构创新:采用MKIR多核倒残差块+MKIRA通道/空间注意力块+GAG分组注意力门,多尺度深度卷积同时捕捉局部细节与全局上下文,适配不同尺寸的病灶特征提取。
结构图

结构创新:采用MKIR多核倒残差块+MKIRA通道/空间注意力块+GAG分组注意力门,多尺度深度卷积同时捕捉局部细节与全局上下文,适配不同尺寸的病灶特征提取。
核心痛点
现有医学图像分割方案存在三类问题:一是大模型(如TransUNet)参数量大、算力要求高,无法部署在床旁诊断等资源受限场景;二是现有轻量模型(如UNeXt)对形状尺寸多变的复杂病灶分割精度不足;三是Transformer类模型忽略局部空间关联,分割边界误差大。
模块亮点
- 结构创新:采用MKIR多核倒残差块+MKIRA通道/空间注意力块+GAG分组注意力门,多尺度深度卷积同时捕捉局部细节与全局上下文,适配不同尺寸的病灶特征提取。
- 性能领先:在6个二分类医学分割数据集上平均DICE达89.75%,对比UNeXt DICE最高提升6.7%,精度甚至超过参数量大数百倍的TransUNet。
- 极致轻量:标准版本仅0.316M参数、0.314G FLOPs,比TransUNet少333倍参数、123倍计算量,比UNeXt少4.7倍参数,完美适配边缘设备部署。
适用场景
CV领域所有医学图像分割任务,适配U型分割架构(UNet、UNeXt、DeepLab等),可解决二分类/多分类医学分割、低算力设备(床旁诊断仪、移动医疗设备)部署、复杂病灶高精度分割三类需求。
插入位置建议
- 编码器特征提取层:替换原有普通卷积/残差块为MKIR块,降低计算量同时提取多尺度特征;2)解码器特征融合层:插入MKIRA注意力块,强化有效特征筛选;3)编码解码跳层连接位置:新增GAG分组注意力门,优化跨层特征融合效果。
适用任务
- CV领域所有医学图像分割任务
- 适配U型分割架构(UNet
- UNeXt
完整代码
mkdc.py
import torch
from torch import nn
from functools import partial
import math
from timm.models.layers import trunc_normal_tf_
from timm.models.helpers import named_apply
def _init_weights(module, name, scheme=''):
if isinstance(module, nn.Conv2d):
if scheme == 'normal':
nn.init.normal_(module.weight, std=.02)
if module.bias is not None:
nn.init.zeros_(module.bias)
elif scheme == 'trunc_normal':
trunc_normal_tf_(module.weight, std=.02)
if module.bias is not None:
nn.init.zeros_(module.bias)
elif scheme == 'xavier_normal':
nn.init.xavier_normal_(module.weight)
if module.bias is not None:
nn.init.zeros_(module.bias)
elif scheme == 'kaiming_normal':
nn.init.kaiming_normal_(module.weight, mode='fan_out', nonlinearity='relu')
if module.bias is not None:
nn.init.zeros_(module.bias)
else:
# efficientnet like
fan_out = module.kernel_size[0] * module.kernel_size[1] * module.out_channels
fan_out //= module.groups
nn.init.normal_(module.weight, 0, math.sqrt(2.0 / fan_out))
if module.bias is not None:
nn.init.zeros_(module.bias)
elif isinstance(module, nn.BatchNorm2d):
nn.init.constant_(module.weight, 1)
nn.init.constant_(module.bias, 0)
elif isinstance(module, nn.LayerNorm):
nn.init.constant_(module.weight, 1)
nn.init.constant_(module.bias, 0)
def act_layer(act, inplace=False, neg_slope=0.2, n_prelu=1):
# activation layer
act = act.lower()
if act == 'relu':
layer = nn.ReLU(inplace)
elif act == 'relu6':
layer = nn.ReLU6(inplace)
elif act == 'leakyrelu':
layer = nn.LeakyReLU(neg_slope, inplace)
elif act == 'prelu':
layer = nn.PReLU(num_parameters=n_prelu, init=neg_slope)
elif act == 'gelu':
layer = nn.GELU()
elif act == 'hswish':
layer = nn.Hardswish(inplace)
else:
raise NotImplementedError('activation layer [%s] is not found' % act)
return layer
class MultiKernelDepthwiseConv(nn.Module):
def __init__(self, in_channels, kernel_sizes, stride, activation='relu6', dw_parallel=True):
super(MultiKernelDepthwiseConv, self).__init__()
self.in_channels = in_channels
self.dw_parallel = dw_parallel
self.kernel_sizes = kernel_sizes
self.dwconvs = nn.ModuleList([
nn.Sequential(
nn.Conv2d(self.in_channels, self.in_channels, kernel_size, stride, kernel_size // 2,
groups=self.in_channels, bias=False),
nn.BatchNorm2d(self.in_channels),
act_layer(activation, inplace=True)
)
for kernel_size in kernel_sizes
])
# Final 1x1 convolution to match the input/output channel size (if needed)
self.final_conv = nn.Conv2d(len(kernel_sizes) * in_channels, in_channels, kernel_size=1, stride=1, padding=0)
self.init_weights('normal')
def init_weights(self, scheme=''):
named_apply(partial(_init_weights, scheme=scheme), self)
def forward(self, x):
# Apply the convolution layers in a loop
outputs = []
for dwconv in self.dwconvs:
dw_out = dwconv(x)
outputs.append(dw_out)
if not self.dw_parallel:
x = x + dw_out
# Concatenate the outputs along the channel dimension, then apply the final convolution to match the input/output channels
concatenated = torch.cat(outputs, dim=1) # Concatenate along the channel axis
out = self.final_conv(concatenated) # 1x1 conv to match the input/output channels
return out
if __name__ == '__main__':
in_channels = 3
kernel_sizes = [3, 5, 7] # Different kernel sizes for the depthwise convolutions
stride = 1
batch_size = 8
height, width = 32, 32
block = MultiKernelDepthwiseConv(in_channels=in_channels, kernel_sizes=kernel_sizes, stride=stride).to('cuda')
input = torch.rand(batch_size, in_channels, height, width).to('cuda')
output = block(input)
print(f"Input shape: {input.size()}")
print(f"Output shape: {output.size()}")
环境与依赖
Python 3.9+
继续浏览
下一篇MLKA MAN 多尺度注意力原理创新:提出MLKA多尺度大核注意力,结合多尺度机制+门控策略,消除块效应的同时捕获多粒度特征;GSAU门控空间注意力单元替代传统MLP,在降低参算量的同时增强空间特征聚合能力。相关资源
模块2026-11-21
MFMSA 多频多尺度注意力
原理创新:双分支注意力串行设计,先通过2D DCT提取多频统计信息做通道校准,抑制噪声通道,再做多尺度空间注意力,聚合不同大小病灶的边界特征,兼顾结构信息和细粒度细节
医学图像分割注意力机制CVPR
医学影像MIT
模块2026-11-21
MSCA 多尺度交叉轴注意力
原理创新:双平行轴向注意力分支做跨轴交互,融合多尺寸条状1D卷积编码多尺度空间信息,全局建模能力远优于普通轴向注意力。
医学图像分割注意力机制计算机视觉
医学影像MIT
模块2026-11-21
TS2-Net 医学分割
原理创新:token shift模块双向整体移动相邻帧同位置token,不破坏单个token的信息完整性,精准捕捉帧间细微动作;
计算机视觉跨模态检索文本视频检索
医学影像MIT