当前位置:   article > 正文

TinyCD论文——阅读笔记

tinycd

TinyCD

题目:TINYCD: A (Not So) Deep Learning Model For Change Detection

论文地址:https://arxiv.org/abs/2207.13159icon-default.png?t=N7T8https://arxiv.org/abs/2207.13159

源码:https://github.com/AndreaCodegoni/Tiny_model_4_CDicon-default.png?t=N7T8https://github.com/AndreaCodegoni/Tiny_model_4_CD

摘要

翻译:

    在本文中,我们提出了一个轻量级且有效的变化检测模型,称为TinyCD。由于工业需求,该模型被设计为比当前最先进的变更检测模型更快、更小。尽管我们的模型比所比较的变化检测模型小13到140倍,并且暴露了至少四分之一的计算复杂性,但我们的模型在LEVIR-CD数据集的F1分数和IoU上至少比目前最先进的模型高出1%,在WHU-CD数据集上超过8%。为了达到这些结果,TinyCD使用了Siamese U-Net架构,以全局时间和局部空间的方式开发低级特征。此外,该方法采用了一种新的策略,即在时空域中混合特征来合并从Siamese主干得到的嵌入,并与MLP块相结合,形成了一种新的空间语义注意机制——混合和注意掩码块(MAMB)。

创新点

  • 轻量有效
  • 主要利用图像的浅层特征做比较
  • MAMB混合和注意掩码模块

模型图如下所示:

MAMB模块图如下所示:

模块及源码

模型采用encoderdecoder结构。主要有以下模块

  • Backbone(efficientnet_b4
  • Mixing block
  • PixelwiseLinear
  • MixingMaskAttentionBlock
  • UpMask

模块源码如下(基于PyTorch),只有上述模块代码,详情见GitHub源码。

  1. from typing import List, Optional
  2. from torch import Tensor, reshape, stack
  3. from torch.nn import (Conv2d, InstanceNorm2d, Module, PReLU, Sequential, Upsample)
  4. class PixelwiseLinear(Module):
  5. def __init__(
  6. self,
  7. fin: List[int],
  8. fout: List[int],
  9. last_activation: Module = None,
  10. ) -> None:
  11. assert len(fout) == len(fin)
  12. super().__init__()
  13. n = len(fin)
  14. self._linears = Sequential(
  15. *[
  16. Sequential(
  17. Conv2d(fin[i], fout[i], kernel_size=1, bias=True),
  18. PReLU()
  19. if i < n - 1 or last_activation is None
  20. else last_activation,
  21. )
  22. for i in range(n)
  23. ]
  24. )
  25. def forward(self, x: Tensor) -> Tensor:
  26. # Processing the tensor:
  27. return self._linears(x)
  28. class MixingBlock(Module):
  29. def __init__(
  30. self,
  31. ch_in: int,
  32. ch_out: int,
  33. ):
  34. super().__init__()
  35. self._convmix = Sequential(
  36. Conv2d(ch_in, ch_out, 3, groups=ch_out, padding=1),
  37. PReLU(),
  38. InstanceNorm2d(ch_out),
  39. )
  40. def forward(self, x: Tensor, y: Tensor) -> Tensor:
  41. # Packing the tensors and interleaving the channels:
  42. mixed = stack((x, y), dim=2)
  43. mixed = reshape(mixed, (x.shape[0], -1, x.shape[2], x.shape[3]))
  44. # Mixing:
  45. return self._convmix(mixed)
  46. class MixingMaskAttentionBlock(Module):
  47. """use the grouped convolution to make a sort of attention"""
  48. def __init__(
  49. self,
  50. ch_in: int,
  51. ch_out: int,
  52. fin: List[int],
  53. fout: List[int],
  54. generate_masked: bool = False,
  55. ):
  56. super().__init__()
  57. self._mixing = MixingBlock(ch_in, ch_out)
  58. self._linear = PixelwiseLinear(fin, fout)
  59. self._final_normalization = InstanceNorm2d(ch_out) if generate_masked else None
  60. self._mixing_out = MixingBlock(ch_in, ch_out) if generate_masked else None
  61. def forward(self, x: Tensor, y: Tensor) -> Tensor:
  62. z_mix = self._mixing(x, y)
  63. z = self._linear(z_mix)
  64. z_mix_out = 0 if self._mixing_out is None else self._mixing_out(x, y)
  65. return (
  66. z
  67. if self._final_normalization is None
  68. else self._final_normalization(z_mix_out * z)
  69. )
  70. class UpMask(Module):
  71. def __init__(
  72. self,
  73. scale_factor: float,
  74. nin: int,
  75. nout: int,
  76. ):
  77. super().__init__()
  78. self._upsample = Upsample(
  79. scale_factor=scale_factor, mode="bilinear", align_corners=True
  80. )
  81. self._convolution = Sequential(
  82. Conv2d(nin, nin, 3, 1, groups=nin, padding=1),
  83. PReLU(),
  84. InstanceNorm2d(nin),
  85. Conv2d(nin, nout, kernel_size=1, stride=1),
  86. PReLU(),
  87. InstanceNorm2d(nout),
  88. )
  89. def forward(self, x: Tensor, y: Optional[Tensor] = None) -> Tensor:
  90. x = self._upsample(x)
  91. if y is not None:
  92. x = x * y
  93. return self._convolution(x)

实验结果

在LEVIR-CD和WHU-CD数据集上进行了实验,并跑出了最优结果。它的优点就在于很少参数的模型跑出了很好的结果!

总结

 该文章用简单的模型完成了变化检测任务,可以说是一个非常优秀的卷积孪生网络,轻量化模型在未来也将会是一个趋势!


本文只是简单的介绍了一下TinyCD模型,更多细节见原文。

本文内容由网友自发贡献,转载请注明出处:【wpsshop博客】
推荐阅读
相关标签
  

闽ICP备14008679号