All models

S2AM

U-Net image harmonization network whose attention module treats the pasted region and the background separately.

Diffusion and generative · 215 operations Checked

100%

Showing the top corner; full diagram not loaded yetShowing a small copy; full diagram not loaded yetLarge diagram, not loaded yet

Open SVG

Loading diagram (24 KB)

Open in a new tab

Click or tap a spot to read it up close. Scroll or drag inside the diagram to move through it. Zoom with + and − or Ctrl and scroll. Press 0 for the whole graph. Swipe inside the diagram to move through it. Use + and − to zoom.

At a glance

Parameters
67M
Operations
215
Framework
PyTorch
Recurrent
No
Published
IEEE Transactions on Image Processing 2020
Cited by
136 (as of 28 October 2026)
Authors
Xiaodong Cun, Chi-Man Pun
Checked
Passed: the trace was replayed operation by operation and matched the model's own output for this input.

Files

The diagram is a drawing of a TorchLens trace of the source code. It contains no code or weights.

Details
Stable ID
m19904
Graph hash
a89386bdf032c2f44902667ed0a252b8c17cbccc0dbf648a468e3a04b3bd616e
Skeleton hash
3ccfbdd0c843640a88122a87f4bd14bf4a4bb741e9c3805589d1cff6c8ac2035
Architecture hash
bd0b63e5db642f18d8c36740b545e0f8587f6cffa7913d83f334ee3506e12172
Diagram SHA-256
be6a2e2d49846fdf9d2ade1baba60d616de4d208405cf083698277257242d9ad
TorchLens version
2.36.0
Renderer
graphviz 2.43.0+pyvips 3.2.0+libvips 8.18.7+render-opts@06c1f0d3
Check
Forward pass replayed in PyTorch

What it is

S2AM, the Spatial-Separated Attention Module, is an attention block for image harmonization, the task of adjusting the pasted region of a composite image so that its style agrees with the background. The authors start from one observation: a spliced image and its harmonized result differ only inside the spliced region and share the same semantic information and appearance outside it.

The module takes a feature map and the binary mask of the spliced region and applies three 1D channel attention gates. One gate selects the features needed to rebuild the image in the non-spliced region. A second weights the features that differ between input and target, and a learnable block after it learns the style transfer. The third weights the features that need no change inside the spliced region. Each gate modifies the channel attention of the Squeeze-and-Excitation Network by adding a max pooling layer.

The network is a U-Net, an encoder-decoder with skip connections. In the form called S2ASC the module replaces the original skip connections, and in the form called S2AD it follows the concatenation of encoder and decoder features. The paper also gives a version for composites without a mask, in which a spatial attention block and an attention loss replace the hard-coded mask. The authors' code trains the network on two synthesized datasets, SCOCO and S-Adobe5k.

Key idea. S2AM applies separate channel attention inside and outside the spliced region of a composite image, so the network learns the masked region and the background individually.

  • S2AM
  • Spatial-Separated Attention Module
  • image harmonization
  • composite image
  • spliced region
  • channel attention
  • S2ASC
  • S2AD
  • SCOCO
  • S-Adobe5k

AI-written summary, based on the paper and checked automatically against it; not reviewed by a person. Corrections welcome.

Cite the paper

@misc{cun2020improvingharmonycompositeimage,
      title={Improving the Harmony of the Composite Image by Spatial-Separated Attention Module}, 
      author={Xiaodong Cun and Chi-Man Pun},
      year={2020},
      eprint={1907.06406},
      archivePrefix={arXiv},
      primaryClass={cs.CV},
      doi={https://doi.org/10.1109/TIP.2020.2975979},
      url={https://arxiv.org/abs/1907.06406}, 
}