# Attention-Based Color Difference Perception for Photographic Images
## 4 Experiment
### Implementation Details  
Network Architecture. The proposed image CD measurement network CD-Attention, which combines the CNN and ViT, uses the ResNet50 and ViT_Base_Patch16 as feature extraction networks. Local texture features are extracted by ResNet50 while the global semantic features are extracted by the ViT, and both have been pre-trained using the trained networks for feature extraction. ResNet50 and the ViT are used to extract features from the reference image and the distorted image, respectively, with the resulting feature map sizes being (B, 768, 56, 56) and (B, 3840, 14, 14), where B represents the batch size set to 8. Subsequently, the nearest neighbor bilinear interpolation and convolution operations are used to process the ViT features of the reference image to obtain the offset for deformable convolution. The size of the offset is (8, 18, 56, 56), and this offset serves as the global receptive field for the current input image, which is used to guide the CNN features. The features extracted from the reference image and the distorted image by ResNet50 are input into the deformable convolution separately, using the offset from the reference image to guide the features. After being processed by the deformable convolution, the features from ResNet50 are transformed into the dimensions of (8, 768, 14, 14). The features of the reference and distorted images processed by deformable convolution are respectively fused with the features extracted from the reference and distorted images by the ViT, resulting in \(\text{f}_{\text{R}}\) and \(\text{f}_{\text{D}}\) with sizes of (8, 4608, 14, 14). Dimensionality reduction is applied to the feature maps, resulting in sizes of (8, 256, 14, 14). Feature fusion of \(\text{f}_{\text{R}}\), \(\text{f}_{\text{D}}\), and (\(\text{f}_{\text{D}}-\text{f}_{\text{R}}\)) results in the final feature map \(\text{f}_{\text{F}}\), with sizes of (8, 768, 14, 14). Finally, a dual-branch prediction model is utilized for score prediction. Convolutional operations are employed to obtain high-frequency global feature maps and low-frequency local feature maps, both with dimensions of (8, 1, 14, 14). The final image CD score is calculated using a weighted average. Training and Testing Details. CD-Attention is trained on a computer equipped with an A100 GPU, using the SPCM dataset for model training. The loss curve of model training is shown in Figure 6, the learning rate is set to 10-4, and the time for one round of training is 16 min and 30 s. A total of 200 rounds of training are conducted, ultimately resulting in the best model loss of 0.05224. Figure 5: Typical images of SPCM. Evaluation Criteria. The results are evaluated using three metrics: standardized residual sum of squares (STRESS), the Pearson linear correlation coefficient (PLCC), and Spearman's rank correlation coefficient (SRCC). These formulas are used to validate the consistency and correlation of the CD-Attention with HSV. The calculation formula for _STRESS_ is as follows:  
\[STRESS=100\sqrt{\frac{\sum_{i=1}^{M}{\left({\Delta E_{i}-F\Delta V_{i}}\right)^ {2}}}{F^{2}{\sum_{i=1}^{M}{\Delta V_{i}^{2}}}}} \tag{8}\]  
where \(M\) is the number of test pairs and \(F\) is the scale correction factor between \(\Delta E\) and \(\Delta V\), defined as:  
\[F=\frac{\sum_{i=1}^{M}{\Delta E_{i}^{2}}}{\sum_{i=1}^{M}{\Delta E_{i}\Delta V _{i}}} \tag{9}\]  
_PLCC_ and _SRCC_ are used to measure the correlation and monotonicity of the CD evaluation network. The calculation formula for _PLCC_ is as follows:  
\[PLCC=\frac{\sum_{i=1}^{M}{\left({\Delta E_{i}-\Delta\overline{E}}\right)}{ \left({\Delta V_{i}-\Delta\overline{V}}\right)}}{\sqrt{\sum_{i=1}^{M}{\left({ \Delta E_{i}-\Delta\overline{E}}\right)^{2}}}\sqrt{\sum_{i=1}^{M}{\left({ \Delta V_{i}-\Delta\overline{V}}\right)^{2}}}} \tag{10}\]  
where \(\Delta\overline{E}=\frac{1}{M}{\sum_{i=1}^{M}{\Delta E_{i}}}\) and \(\Delta\overline{V}=\frac{1}{M}{\sum_{i=1}^{M}{\Delta V_{i}}}\) are the mean predicted and perceptual CDs, respectively.