模块更新于 2026-11-20· 浏览 1· 下载 0
SFS-Conv 空频选择卷积
一层卷积双感知:SPU 用多尺度卷积核加层级残差扩大感受野,FPU 用分数阶 Gabor 变换提取高频纹理、抑制散斑噪声,不用额外堆注意力模块
结构图

一层卷积双感知:SPU 用多尺度卷积核加层级残差扩大感受野,FPU 用分数阶 Gabor 变换提取高频纹理、抑制散斑噪声,不用额外堆注意力模块
论文信息
- 论文:Unleashing Channel Potential: Space-Frequency Selection Convolution for SAR Object Detection
- 出处:CVPR 2024
核心痛点
标准卷积局部又线性,单个卷积层内通道冗余严重;SAR 图像目标小、散斑噪声强,仅凭空间外观难以识别;现有方法靠额外堆空间或频率注意力模块补线索,进一步推高复杂度和冗余。
模块亮点
- 一层卷积双感知:SPU 用多尺度卷积核加层级残差扩大感受野,FPU 用分数阶 Gabor 变换提取高频纹理、抑制散斑噪声,不用额外堆注意力模块
- 消融涨点实打实:HRSID 消融中单用 SPU 或 FPU 即达 94.66% / 94.45% AP50,合并到 95.71%,比换成普通 3×3 卷积高 5.32%;两路直接相加只有 94.68%,CSU 无参数选择融合明显更好
- 轻量性能两全:SFS-CNet 仅 1.86M 参数,以 YOLOv8s 18% 的参数量、24% 的 FLOPs,在 HRSID、SSDD、SAR-AIRcraft-1.0 上分别拿到 96.2%、99.6% AP50 和 89.7% mAP,单图推理 8.6ms
适用场景
领域为 SAR 遥感目标检测,原文实验覆盖舰船与飞机识别;可迁移到光学遥感小目标检测、红外小目标检测、海面监测等杂波强、目标小的任务。
插入位置建议
- 替换检测网络骨干或 Neck 里的标准 3×3 卷积块,原文 SFS-CNet 骨干就是 CBR 与 SFS-Conv 连续堆叠而成
- 嵌入 YOLO 系列的 C2f / Bottleneck 结构,替换内部卷积,通道数不变直接用
- 放在骨干浅层对付散斑噪声,让后续层拿到更干净的特征
适用任务
- SAR 遥感目标检测
- 原文实验覆盖舰船与飞机识别
完整代码
sfs-conv.py
import math
import numpy as np
import torch
import torch.nn as nn
import torch.nn.functional as F
"""《Unleashing channel potential: Space-frequency selection convolution for SAR object detection》CVPR 2024
深度卷积神经网络 (DCNN) 在合成孔径雷达 (SAR) 目标检测中取得了卓越的性能,但这是以巨大的计算资源为代价的,部分原因是在单个卷积层中提取了冗余特征。
近期的研究要么深入研究模型压缩方法,要么专注于精心设计的轻量级模型,而这两种方法都会导致性能下降。本文提出了一种用于 SAR 目标检测的高效卷积模块 SFS-Conv,该模块通过分流-感知-选择策略增加了每个卷积层内的特征多样性。
具体而言,我们将输入特征图分流到空间和频率两个方面。前者通过动态调整感受野来感知各种目标的上下文,而后者通过分数阶 Gabor 变换来捕捉丰富的频率变化和纹理特征。
为了自适应地融合空间和频率方面的特征,我们提出了一个无参数特征选择模块,以确保保留最具代表性和独特性的信息。基于 SFS-Conv,我们构建了一个轻量级 SAR 目标检测网络 SFS-CNet。
实验结果表明,SFS-CNet 在一系列 SAR 物体检测基准上优于最先进的 (SoTA) 模型,同时降低了模型尺寸和计算成本。
"""
def autopad(k, p=None, d=1):
"""Pad to 'same' shape outputs."""
if d > 1:
k = d * (k - 1) + 1 if isinstance(k, int) else [d * (x - 1) + 1 for x in k]
if p is None:
p = k // 2 if isinstance(k, int) else [x // 2 for x in k] # auto-pad
return p
class Conv(nn.Module):
default_act = nn.SiLU()
def __init__(self, c1, c2, k=1, s=1, p=None, g=1, d=1, act=True):
super().__init__()
self.conv = nn.Conv2d(
c1, c2, k, s, autopad(k, p, d), groups=g, dilation=d, bias=False
)
self.bn = nn.BatchNorm2d(c2)
self.act = (
self.default_act
if act is True
else act
if isinstance(act, nn.Module)
else nn.Identity()
)
def forward(self, x):
c = self.conv(x)
c = self.bn(c)
c = self.act(c)
return c
class ChannelAttention(nn.Module):
def __init__(self):
super().__init__()
self.pool = nn.AdaptiveAvgPool2d(1)
self.act = nn.Sigmoid()
def forward(self, x: torch.Tensor):
return self.act(self.pool(x))
class SpatialAttention(nn.Module):
def __init__(self, kernel_size=3):
super().__init__()
padding = 3 if kernel_size == 7 else 1
self.cv1 = nn.Conv2d(2, 1, kernel_size, padding=padding, bias=False)
self.act = nn.Sigmoid()
def forward(self, x):
x = self.cv1(torch.cat([torch.mean(x, 1, keepdim=True), torch.max(x, 1, keepdim=True)[0]], 1,))
return self.act(x)
class FractionalGaborFilter(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, order, angles, scales):
super(FractionalGaborFilter, self).__init__()
self.real_weights = nn.ParameterList()
self.imag_weights = nn.ParameterList()
for angle in angles:
for scale in scales:
# real_weight, imag_weight = self.generate_fractional_gabor(in_channels, out_channels, kernel_size, order, angle, scale)
real_weight = self.generate_fractional_gabor(in_channels, out_channels, kernel_size, order, angle, scale)
self.real_weights.append(nn.Parameter(real_weight))
# self.imag_weights.append(nn.Parameter(imag_weight))
def generate_fractional_gabor(
self, in_channels, out_channels, size, order, angle, scale):
x, y = np.meshgrid(np.linspace(-1, 1, size[0]), np.linspace(-1, 1, size[1]))
x_theta = x * np.cos(angle) + y * np.sin(angle)
y_theta = -x * np.sin(angle) + y * np.cos(angle)
real_part = np.exp(-((x_theta**2 + (y_theta / scale) ** 2) ** order)) * np.cos(2 * np.pi * x_theta / scale)
# imag_part = np.exp(-((x_theta ** 2 + (y_theta / scale) ** 2) ** order)) * np.sin(2 * np.pi * x_theta / scale)
# Reshape to match the specified out_channels and size
real_weight = torch.tensor(real_part, dtype=torch.float32).view(1, 1, size[0], size[1])
# imag_weight = torch.tensor(imag_part, dtype=torch.float32).view(1, 1, size[0], size[1])
# Repeat along the out_channels dimension
real_weight = real_weight.repeat(out_channels, 1, 1, 1)
# imag_weight = imag_weight.repeat(out_channels, 1, 1, 1)
return real_weight # , imag_weight
def forward(self, x):
real_weights = [weight for weight in self.real_weights]
# imag_weights = [weight for weight in self.imag_weights]
real_result = sum(weight * x for weight in real_weights)
# imag_result = sum(weight * x for weight in imag_weights)
return real_result # - imag_result
class GaborSingle(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, order, angles, scales):
super(GaborSingle, self).__init__()
self.gabor = FractionalGaborFilter(in_channels, out_channels, kernel_size, order, angles, scales)
self.t = nn.Parameter(
torch.randn(out_channels, in_channels, kernel_size[0], kernel_size[1]),
requires_grad=True,
)
nn.init.normal_(self.t)
self.relu = nn.ReLU(inplace=True)
def forward(self, x):
out = self.gabor(self.t)
out = F.conv2d(x, out, stride=1, padding=(out.shape[-2] - 1) // 2)
out = self.relu(out)
out = F.dropout(out, 0.3)
out = F.pad(out, (1, 0, 1, 0), mode="constant", value=0) # Padding on the left and top
out = F.max_pool2d(out, 2, stride=1, padding=0)
return out
class GaborFPU(nn.Module):
def __init__(
self,
in_channels,
out_channels,
order=0.25,
angles=[0, 45, 90, 135],
scales=[1, 2, 3, 4],
):
super(GaborFPU, self).__init__()
self.gabor = GaborSingle(in_channels // 4, out_channels // 4, (3, 3), order, angles, scales)
self.fc = nn.Conv2d(out_channels, out_channels, kernel_size=1)
def forward(self, x):
channels_per_group = x.shape[1] // 4
x1, x2, x3, x4 = torch.split(x, channels_per_group, 1)
x_out = torch.cat(
[self.gabor(x1), self.gabor(x2), self.gabor(x3), self.gabor(x4)], dim=1
)
x_out = self.fc(x_out)
if x.shape[1] == x_out.shape[1]:
x_out = x_out + x
return x_out
class FrFTFilter(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, f, order):
super(FrFTFilter, self).__init__()
self.register_buffer(
"weight",
self.generate_FrFT_filter(in_channels, out_channels, kernel_size, f, order),
)
def generate_FrFT_filter(self, in_channels, out_channels, kernel, f, p):
N = out_channels
d_x = kernel[0]
d_y = kernel[1]
x = np.linspace(1, d_x, d_x)
y = np.linspace(1, d_y, d_y)
[X, Y] = np.meshgrid(x, y)
real_FrFT_filterX = np.zeros([d_x, d_y, out_channels])
real_FrFT_filterY = np.zeros([d_x, d_y, out_channels])
real_FrFT_filter = np.zeros([d_x, d_y, out_channels])
for i in range(N):
real_FrFT_filterX[:, :, i] = np.cos(-f * (X) / math.sin(p) + (f * f + X * X) / (2 * math.tan(p)))
real_FrFT_filterY[:, :, i] = np.cos(-f * (Y) / math.sin(p) + (f * f + Y * Y) / (2 * math.tan(p)))
real_FrFT_filter[:, :, i] = (real_FrFT_filterY[:, :, i] * real_FrFT_filterX[:, :, i])
g_f = np.zeros((kernel[0], kernel[1], in_channels, out_channels))
for i in range(N):
g_f[:, :, :, i] = np.repeat(real_FrFT_filter[:, :, i : i + 1], in_channels, axis=2)
g_f = np.array(g_f)
g_f_real = g_f.reshape((out_channels, in_channels, kernel[0], kernel[1]))
return torch.tensor(g_f_real).type(torch.FloatTensor)
def forward(self, x):
x = x * self.weight
return x
def generate_FrFT_list(self, in_channels, out_channels, kernel, f_list, p):
FrFT_list = []
for f in f_list:
FrFT_list.append(self.generate_FrFT_filter(in_channels, out_channels, kernel, f, p))
return FrFT_list
class FrFTSingle(nn.Module):
def __init__(self, in_channels, out_channels, kernel_size, f, order):
super().__init__()
self.fft = FrFTFilter(in_channels, out_channels, kernel_size, f, order)
self.t = nn.Parameter(
torch.randn(out_channels, in_channels, kernel_size[0], kernel_size[1]),
requires_grad=True,
)
nn.init.normal_(self.t)
self.relu = nn.ReLU(inplace=True)
def forward(self, x):
out = self.fft(self.t)
out = F.conv2d(x, out, stride=1, padding=(out.shape[-2] - 1) // 2)
out = self.relu(out)
out = F.dropout(out, 0.3)
out = F.pad(out, (1, 0, 1, 0), mode="constant", value=0)
out = F.max_pool2d(out, 2, stride=1, padding=0)
return out
class FourierFPU(nn.Module):
def __init__(self, in_channels, out_channels, order=0.25):
super().__init__()
self.fft1 = FrFTSingle(in_channels // 4, out_channels // 4, (3, 3), 0.25, order)
self.fft2 = FrFTSingle(in_channels // 4, out_channels // 4, (3, 3), 0.50, order)
self.fft3 = FrFTSingle(in_channels // 4, out_channels // 4, (3, 3), 0.75, order)
self.fft4 = FrFTSingle(in_channels // 4, out_channels // 4, (3, 3), 1.00, order)
self.fc = Conv(out_channels, out_channels, 1)
def forward(self, x):
channels_per_group = x.shape[1] // 4
x1, x2, x3, x4 = torch.split(x, channels_per_group, 1)
x_out = torch.cat([self.fft1(x1), self.fft2(x2), self.fft3(x3), self.fft4(x4)], dim=1)
x_out = self.fc(x_out)
if x.shape[1] == x_out.shape[1]:
x_out = x_out + x
return x_out
class SPU(nn.Module):
def __init__(self, in_channels, out_channels):
super().__init__()
self.c1 = Conv(in_channels // 2, in_channels // 2, 3, g= in_channels // 2)
self.c2 = Conv(in_channels // 2, in_channels // 2, 5, g= in_channels // 2)
self.c3 = Conv(in_channels, out_channels, 1)
def forward(self, x):
x1, x2 = torch.split(x, x.shape[1] // 2, dim=1)
x1 = self.c1(x1)
x2 = self.c2(x2 + x1)
x_out = torch.cat([x1, x2], dim=1)
x_out = self.c3(x_out)
if x.shape[1] == x_out.shape[1]:
x_out = x_out + x
return x_out
class SFSConv(nn.Module):
def __init__(
self, in_channels, out_channels, order=0.25, filter="FrGT"):
super().__init__()
self.PWC0 = Conv(in_channels, in_channels // 2, 1)
self.PWC1 = Conv(in_channels, in_channels // 2, 1)
self.SPU = SPU(in_channels // 2, out_channels)
assert filter in (
"FrFT",
"FrGT",
), "The filter type must be either Fractional Fourier Transform(FrFT) or Fractional Gabor Transform(FrGT)."
if filter == "FrFT":
self.FPU = FourierFPU(in_channels // 2, out_channels, order)
elif filter == "FrGT":
self.FPU = GaborFPU(in_channels // 2, out_channels, order)
self.PWC_o = Conv(out_channels, out_channels, 1)
self.advavg = nn.AdaptiveAvgPool2d(1)
def forward(self, x):
x_spa = self.SPU(self.PWC0(x))
x_fre = self.FPU(self.PWC1(x))
out = torch.cat([x_spa, x_fre], dim=1)
out = F.softmax(self.advavg(out), dim=1) * out
out1, out2 = torch.split(out, out.size(1) // 2, dim=1)
return self.PWC_o(out1 + out2)
if __name__ == '__main__':
channel = 32
height = width = 20
block = SFSConv(channel, channel).to('cuda')
input = torch.rand(1, 32, 4, 4).to('cuda')
output = block(input)
print(input.size())
print(output.size())环境与依赖
Python 3.9+
继续浏览
下一篇SHIP 协同高阶交互范式频域等价变换:借卷积定理把空间域相关运算搬进频域,FFT 后逐元素相乘再逆变换,与全局交互数学等价、计算轻量相关资源
模块2026-11-20
AGCA 自适应图通道注意力
把图卷积搬进通道注意力:每个通道当作一个图节点,用"单位矩阵 + 自注意力对角矩阵 + 可学习邻接矩阵"三张图自适应建模通道间关系,在特征层面做非局部操作,避开逐像素计算
目标检测缺陷检测AGCA
计算机视觉MIT
模块2026-11-20
AKConv 可变核卷积
参数量任意:坐标生成算法让卷积核能取 1、2、3、4、5、6、7… 任意数量的参数,标准卷积和 Deformable Conv 都做不到;参数量随核大小线性增长
计算机视觉目标检测AKConv
计算机视觉MIT
模块2026-11-20
CBAM 卷积块注意力模块
双池化通道注意力:通道分支同时用平均池化和最大池化聚合空间信息,过共享 MLP 后逐元素相加,最大池化补平均池化的不足;
计算机视觉注意力机制CBAM
计算机视觉MIT