Introduction
Arbitrary Style Transfer (AST) is a fundamental task in computer vision that involves synthesizing an image by combining the content of one image with the artistic style of another. While recent advancements in attention-based AST (Attn-AST) have significantly improved the ability to capture global stylistic patterns, they frequently struggle with semantic consistency. Standard "Universal Attention" (UA) mechanisms treat all pixels as potential matches, often leading to "style bleeding" where textures from one semantic region (e.g., grass) are incorrectly applied to another (e.g., a person's clothing). This results in style discontinuity, semantic misalignment, and blurred textures due to the averaging effect of standard attention.
The SCSA Framework
To address these limitations, we introduce Semantic Continuous-Sparse Attention (SCSA), a modular, "plug-and-play" component designed to enforce semantic boundaries and preserve sharp textures. SCSA replaces standard UA with a dual-pathway, semantically-aware architecture:
- Semantic Adaptive Instance Normalization (S-AdaIN): Before the attention mechanism, images are segmented using K-means clustering. S-AdaIN aligns feature statistics within corresponding semantic regions, providing a refined starting point for stylization.
- Semantic Continuous Attention (SCA): This pathway ensures global style consistency within a region. By allowing a content point to attend to all key points within the same semantic category in the style image, SCA captures smooth color transitions and overall regional vividness.
- Semantic Sparse Attention (SSA): To counteract the blurring inherent in continuous averaging, SSA identifies and focuses on the most similar key point within the correct semantic region. This preserves sharp, local stylistic details like distinct brushstrokes.
SCSA is architecture-agnostic and can be integrated into various backbones, including CNNs (SANet), Transformers (StyTr²), and Diffusion models (StyleID).
Experimental Evaluation
The effectiveness of SCSA was evaluated using a dataset of content-style pairs accompanied by semantic maps. The framework was benchmarked against eight state-of-the-art methods, including STROTSS, MAST, and GLStyleNet. Evaluation metrics included Semantic Style Loss (SSL) for semantic alignment and Content Feature Structural Distance (CFSD) for structural preservation.
Results and Discussion
Qualitative and quantitative results demonstrate the superiority of SCSA-enhanced models across all tested backbones.
As shown in the comparison above, SCSA effectively eliminates style bleeding and maintains sharp textures across diverse content types. Quantitatively, SCSA-enhanced models showed a dramatic reduction in SSL (e.g., from 1.65 to 0.87 for SANet) and improved CFSD scores. Furthermore, a user study revealed a strong preference for SCSA-stylized images, with an 84.2% preference rate for StyTr² + SCSA over the baseline.
Conclusion and Future Work
SCSA provides a robust solution for semantic inconsistencies in arbitrary style transfer by leveraging a dual-pathway attention mechanism. While it introduces some computational overhead—increasing inference time from 1.2ms to 3.9ms for a 512x512 image—the gains in visual quality and semantic accuracy are substantial. Future research will focus on optimizing the module's efficiency to enable real-time applications on mobile devices and reducing its reliance on high-precision semantic maps.
Summary updated