Image tampering region detection method and device, and electronic device

CN122887876APending Publication Date: 2026-10-09HANGZHOU AKEY ME CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611157018.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-09

AI Technical Summary

Technical Problem

[0004]有鉴于此,本申请提供了一种图像篡改区域的检测方法、装置及电子设备,以解决聊天图像篡改区域检测准确性较低的问题

Benefits of technology

[0017]本申请实施例提供的图像篡改区域的检测方法,通过主干网络进行特征提取,并利用其中的注意力模块对特征图进行方向边缘增强,这有助于突出篡改区域的边界与纹理突变痕迹,提升对微弱篡改线索的感知能力。随后,颈部网络对增强后的特征进行融合,并引入频率门控模块在频域对融合特征进行残差补偿,能够有效恢复和强化因压缩等操作而被弱化的高频异常信息,并增强对篡改引起的细微频率差异的敏感性,弥补空间域处理的不足,从而提升模型在压缩、缩放等后处理干扰下的检测稳定性与定位鲁棒性。因此,本申请通过方向边缘增强与频域残差补偿的协同处理,全面强化了特征表达,实现了对聊天图像中篡改区域的精准检测,改善了弱痕迹与小尺度篡改的定位效果,并提升了跨传播条件与跨数据分布下的泛化能力。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122887876A_ABST
    Figure CN122887876A_ABST
Patent Text Reader

Abstract

The application discloses a kind of image tampering area detection method, device and electronic equipment, it is related to image processing technical field, the method comprises: obtaining the chat image to be detected;Using the backbone network of tampering detection model carries out feature extraction to chat image, obtains first input feature map;Using the attention module in backbone network, first input feature map is enhanced in direction edge, and first output feature map is obtained;Using the neck network of tampering detection model carries out feature fusion to first output feature map, and second input feature map is obtained;Using the frequency gate module in neck network, frequency domain residual error compensation is carried out to second input feature map, and second output feature map is obtained;Tampering area detection is carried out to second output feature map, and the tampering area detection result corresponding to chat image is obtained.By implementing the technical scheme of the application, the tampering area with weak traces or fuzzy boundary in the chat image can be detected more accurately.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of image processing technology, specifically to a method, apparatus, and electronic device for detecting image tampering areas. Background Technology

[0002] Image tampering detection is an important research direction in the fields of digital forensics and computer vision, and it is urgently needed in scenarios such as social media dialogue forensics and electronic evidence review. Unlike general natural image tampering, tampering in chat images is mostly local replacement, splicing, or editing. The tampered area is often small in scale, with blurred boundaries and faint traces. At the same time, such images often undergo post-processing such as screenshot compression, secondary forwarding, platform recoding, and scaling and cropping during dissemination, further weakening the traces of tampering.

[0003] Current deep learning-based tampering region detection methods typically suffer from the following problems when applied to chat images: On the one hand, they are not good at capturing subtle traces such as boundary discontinuities, splicing gaps, and local texture abrupt changes caused by tampering, resulting in low detection accuracy for small-scale, weakly traced tampering regions; on the other hand, under post-processing interference such as compression and resampling, the model's response to tampering traces is prone to instability, and its localization robustness and generalization ability across propagation conditions and data distributions need to be improved. Summary of the Invention

[0004] In view of this, this application provides a method, apparatus and electronic device for detecting image tampering areas, in order to solve the problem of low accuracy in detecting tampering areas in chat images.

[0005] In a first aspect, this application provides a method for detecting image tampering regions, comprising: acquiring a chat image to be detected; inputting the chat image into the backbone network of a tampering detection model, and using the backbone network to extract features from the chat image to obtain a first input feature map; using an attention module in the backbone network to perform directional edge enhancement on the first input feature map to obtain a first output feature map; inputting the first output feature map into the neck network of the tampering detection model, and using the neck network to perform feature fusion on the first output feature map to obtain a second input feature map; using a frequency gating module in the neck network to perform frequency domain residual compensation on the second input feature map to obtain a second output feature map; and performing tampering region detection on the second output feature map to obtain a tampering region detection result corresponding to the chat image.

[0006] In some optional implementations, the attention module includes multiple convolutional kernels with preset directions; performing directional edge enhancement on the first input feature map to obtain a first output feature map includes: performing channel adaptation on the first input feature map to obtain first basis features; using convolutional kernels to perform directional filtering on the first basis features to obtain edge response features with multiple preset directions; performing convolutional fusion on the multiple edge response features to obtain fused edge features; performing spatial attention calculation on the fused edge features to generate a spatial attention map; and obtaining the first output feature map based on the fused edge features, the spatial attention map, and the first basis features.

[0007] In some optional implementations, spatial attention calculation is performed on the fused edge features to generate a spatial attention map, including: performing channel compression convolution on the fused edge features to obtain intermediate features; performing convolution mapping on the intermediate features to obtain mapped features; and performing normalization processing on the mapped features to generate a spatial attention map.

[0008] In some optional implementations, the attention module further includes a learnable scalar; and obtaining a first output feature map based on fused edge features, a spatial attention map, and a first basis feature, including: multiplying the fused edge features by the spatial attention map to obtain weighted edge features; multiplying the weighted edge features by the learnable scalar to obtain weighted adjusted features; and adding the weighted adjusted features to the first basis feature to obtain the first output feature map.

[0009] In some optional implementations, the frequency gating module includes a preset mask; performing frequency domain residual compensation on the second input feature map to obtain a second output feature map includes: channel alignment of the second input feature map to obtain a second basis feature; frequency domain transformation of the second basis feature to obtain a first spectral feature; filtering the first spectral feature using the preset mask to obtain a second spectral feature; spatial domain recovery of the second spectral feature to obtain a spatial domain residual feature; convolution processing of the spatial domain residual feature to obtain an enhanced residual feature; and obtaining a second output feature map based on the enhanced residual feature and the second basis feature.

[0010] In some optional implementations, spatial domain recovery is performed on the second spectral feature to obtain spatial domain residual features, including: performing an inverse frequency domain transformation on the second spectral feature to obtain inverse transformation features; and extracting the real part of the inverse transformation features to obtain spatial domain residual features.

[0011] In some optional implementations, the frequency gating module includes learnable gating parameters; and obtains a second output feature map based on enhanced residual features and second basis features, including: performing activation processing on the learnable gating parameters to obtain gating coefficients; multiplying the enhanced residual features and the gating coefficients to obtain gating adjustment features; and adding the gating adjustment features to the second basis features to obtain the second output feature map.

[0012] In some optional implementations, multiple sample images of the labeled tampered areas are acquired; the tampering detection model is trained using the multiple sample images to obtain the trained tampering detection model.

[0013] Secondly, this application provides an image tampering region detection device, comprising: a first acquisition module for acquiring a chat image to be detected; an extraction module for inputting the chat image into the backbone network of a tampering detection model and extracting features from the chat image using the backbone network to obtain a first input feature map; an enhancement module for enhancing the directional edges of the first input feature map using an attention module in the backbone network to obtain a first output feature map; a fusion module for inputting the first output feature map into the neck network of the tampering detection model and fusing features from the first output feature map using the neck network to obtain a second input feature map; a compensation module for compensating the frequency domain residual of the second input feature map using a frequency gating module in the neck network to obtain a second output feature map; and a detection module for detecting tampering regions on the second output feature map to obtain a tampering region detection result corresponding to the chat image.

[0014] Thirdly, this application provides an electronic device, including: a memory and a processor, which are communicatively connected to each other. The memory stores computer instructions, and the processor executes the computer instructions to perform the image tampering region detection method described in the first aspect or any corresponding embodiment.

[0015] Fourthly, this application provides a computer-readable storage medium storing computer instructions for causing a computer to execute the image tampering region detection method described in the first aspect or any corresponding embodiment.

[0016] Fifthly, this application provides a computer program product, including computer instructions for causing a computer to execute the image tampering region detection method described in the first aspect or any corresponding embodiment.

[0017] The image tampering region detection method provided in this application extracts features through a backbone network and uses its attention module to enhance the directional edges of the feature map. This helps to highlight the boundaries and texture abrupt changes of the tampered region, improving the ability to perceive weak tampering clues. Subsequently, the neck network fuses the enhanced features and introduces a frequency gating module to perform residual compensation on the fused features in the frequency domain. This effectively restores and strengthens high-frequency anomalous information weakened by operations such as compression, and enhances the sensitivity to subtle frequency differences caused by tampering, compensating for the deficiencies of spatial domain processing. This improves the detection stability and localization robustness of the model under post-processing interference such as compression and scaling. Therefore, this application comprehensively enhances feature representation through the synergistic processing of directional edge enhancement and frequency domain residual compensation, achieving accurate detection of tampered regions in chat images, improving the localization effect of weak traces and small-scale tampering, and enhancing the generalization ability across propagation conditions and data distributions. Attached Figure Description

[0018] To more clearly illustrate the technical solutions in the specific embodiments or related technologies of this application, the drawings used in the description of the specific embodiments or related technologies will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.

[0019] Figure 1 This is a schematic flowchart of an image tampering region detection method according to an embodiment of this application; Figure 2 This is a schematic diagram of the overall structure of the tamper detection model according to an embodiment of this application; Figure 3 This is a schematic diagram of the attention module according to an embodiment of this application; Figure 4 This is a schematic diagram of the frequency gating module structure according to an embodiment of this application; Figure 5 This is a schematic diagram comparing the first detection effect according to an embodiment of this application; Figure 6 This is a schematic diagram comparing the second detection effect according to an embodiment of this application; Figure 7 This is a schematic diagram comparing the third detection effect according to the embodiments of this application; Figure 8 This is a structural block diagram of an image tampering area detection device according to an embodiment of this application; Figure 9 This is a schematic diagram of the hardware structure of an electronic device according to an embodiment of this application. Detailed Implementation

[0020] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0021] The terms "first" and "second" are used for descriptive purposes only and should not be construed as indicating or implying relative importance or implicitly specifying the number of technical features indicated. Therefore, a feature defined as "first" or "second" may explicitly or implicitly include one or more of that feature. In the description of this application, "multiple" means two or more, unless otherwise explicitly specified.

[0022] Image tampering detection is an important research direction in computer vision and digital forensics, with significant application value in scenarios such as online public opinion governance, electronic evidence review, forensic identification, and platform risk control. With the widespread use of image editing software, mobile image editing tools, and generative artificial intelligence technologies, image content can be quickly modified and become highly deceptive. Relying solely on manual verification is insufficient to simultaneously meet the requirements of accuracy, efficiency, and scalability. In recent years, deep learning-based tampering detection and tampering region localization methods have gradually become the mainstream technical approach. These methods can automatically learn multi-scale representations of tampering traces from large-scale data, offering advantages such as strong feature representation capabilities and flexible engineering deployment.

[0023] In conversational evidence collection scenarios, users often send various image information during conversations, such as transfer vouchers and screenshots of contract documents. Once such chat images are tampered with, it may lead to disputes, fraud, or distorted evidence. Compared with general natural image tampering, tampering in chat images usually presents as local replacement, splicing, or editing at the content level. The tampered area is often small in scale, with indistinct boundaries and weak traces. Moreover, in the actual propagation chain, it is often accompanied by distortion factors such as screenshot compression, secondary forwarding, platform recoding, and scaling and cropping, which further weaken the traces of tampering. As a result, existing detection models are prone to missed detections and false detections in such scenarios.

[0024] Furthermore, the relevant general tampering datasets cover typical tampering types such as copying and moving, splicing and replacing, and removal and padding, which can provide models with effective tampering priors and general localization capabilities. However, the aforementioned public datasets and chat images still have certain differences in content structure, imaging and propagation methods, and noise distribution, resulting in insufficient robustness and generalization ability when directly transferring and applying them.

[0025] The image tampering region detection method provided in this application addresses the issues of missed and false detections caused by the small scale, indistinct boundaries, and weak traces of tampered regions in chat images. It introduces an attention module into the backbone network to enhance the directional edges of the extracted first input feature map, thereby strengthening the response to edge discontinuities and texture abrupt changes caused by tampering and improving the model's ability to perceive small-scale, weakly traced tampering regions. Secondly, to address the problem that tampering traces are further weakened during chat image propagation due to distortion factors such as screenshot compression, secondary forwarding, platform recoding, and scaling / cropping, a frequency gating module is introduced into the neck network to perform frequency domain residual compensation on the second input feature map after feature fusion. This compensates for high-frequency abnormal information weakened by post-processing such as compression and scaling, improving the localization stability and robustness of the detection. Furthermore, to address the issue that direct transfer of publicly available tampered datasets and chat images results in insufficient robustness and generalization ability due to differences in content structure and noise distribution, a complementary mechanism is formed by enhancing the directional edges of the backbone network and compensating for the frequency domain residuals of the neck network. The former focuses on spatial domain directional detail extraction, while the latter focuses on frequency domain robust enhancement. The two work together to improve the stability and generalization ability of the model's feature representation under different data distributions, thereby enabling the model trained on the publicly available dataset to be effectively transferred to chat image tampering detection in dialogue scenarios.

[0026] According to an embodiment of this application, an embodiment of a method for detecting image tampering regions is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.

[0027] This embodiment provides a method for detecting image tampering regions, which can be used in electronic devices such as laptops and desktop computers. Figure 1 This is a flowchart of an image tampering region detection method according to an embodiment of this application, such as... Figure 1 As shown, the process includes the following steps: Step S101: Obtain the chat image to be detected.

[0028] Chat images refer to pictures sent between users in conversational scenarios such as instant messaging and social media platforms. Common content includes transfer vouchers, contract screenshots, and invoices. Common forms of tampering include partial replacement, splicing, copying and moving, and removal / filling. The tampered areas are usually small in scale, with indistinct boundaries and weak traces. Furthermore, in the actual transmission chain, distortion factors such as screenshot compression, secondary forwarding, platform recoding, and scaling / cropping often occur, further weakening the traces of tampering. Specifically, images sent between users can be extracted from the conversation records of instant messaging applications and social media platforms as chat images to be detected. Alternatively, chat screenshot files stored locally on the electronic device can be read directly, or the image data stream to be identified can be received through a network interface. The source of acquisition is not limited, as long as the image itself is a picture transmitted in a conversational context and may have been partially replaced or edited.

[0029] Step S102: Input the chat image into the backbone network of the tamper detection model, and use the backbone network to extract features from the chat image to obtain the first input feature map.

[0030] A tampering detection model is a deep learning model used to detect tampering in chat images and locate the tampered region. Its main task is to perform end-to-end image analysis and output the location and confidence score of the tampered target. This model typically includes feature extraction, feature fusion, and a detection head, and can be implemented, for example, by improving the YOLOv11 object detection network. Its overall network architecture can be as follows: Figure 2 As shown, Figure 2 The diagram shows the overall model structure, illustrating the hierarchical connections between the backbone, neck, and head, as well as the embedding positions of the attention module (DHIA) and frequency gating module (FREG) within the network.

[0031] The backbone network is the core structure of a tamper detection model responsible for extracting multi-level, multi-scale semantic features from the original input image. It is typically composed of a series of stacked convolutional layers or transformer blocks, providing basic feature maps for subsequent modules. For example, the backbone part of YOLOv11 can be used as the backbone network, and subsequent attention modules can be embedded at the feature output position of the third layer of the backbone network.

[0032] The first input feature map is an intermediate feature map that the backbone network passes to a specific downstream module (i.e., the attention module) after completing the initial feature extraction. It is the initial input data for that module. For example, this feature map can be output by the third layer of the backbone network, with 256 channels and a size represented as (B, 256, H, W), where B is the batch size, and H and W are the height and width of the feature map, respectively.

[0033] Specifically, the acquired chat images undergo basic preprocessing such as scaling or cropping to the required size for the model (e.g., uniformly scaling or cropping to 960×960) before being fed as input tensors into the backbone network of the tamper detection model. The backbone network typically consists of a series of convolutional operations and downsampling operations stacked together, capable of extracting multi-level features such as edges, textures, object parts, and even semantic information from the original pixels layer by layer, ultimately outputting a basic feature map rich in discriminative information. This feature map is the first input feature map.

[0034] Step S103: Using the attention module in the backbone network, the first input feature map is enhanced with directional edges to obtain the first output feature map.

[0035] The attention module, short for Directional High-frequency Injection Attention (DHIA), is a computational unit embedded in a feature extraction network. It allows the model to automatically focus on key regions in the input feature map. It generates spatial or channel weights through a mechanism to enhance or suppress the original features.

[0036] The first output feature map is a new feature map output by the attention module after the first input feature map has been processed by attention enhancement. It retains the semantic basis of the original features and injects more edge or high-frequency information into key regions. It will then be fed into the next stage of the network (i.e., the neck network).

[0037] Specifically, an attention module is embedded in the backbone network. This module receives the first input feature map as its processing object. It extracts high-frequency edge responses from the image along multiple preset spatial directions (such as horizontal, vertical, and diagonal) to capture directional boundary discontinuities or texture abrupt changes caused by tampering (such as splicing, copying, and moving). Then, the attention module uses an adaptive attention weighting mechanism to spatially select the key regions most likely to correspond to real tampering traces, selectively enhances this information, and integrates the enhanced results with the original features to output a first output feature map that highlights edge details while preserving the original semantic basis.

[0038] Step S104: Input the first output feature map into the neck network of the tamper detection model, and use the neck network to perform feature fusion on the first output feature map to obtain the second input feature map.

[0039] The neck network is a network structure located between the backbone network and the detection head. It is mainly responsible for fusing and recombining feature maps from different levels to construct a feature pyramid containing rich scale information. For example, the Neck part of YOLOv11 can be used as the neck network, and subsequent frequency residual enhancement gating modules can be embedded in the mid-scale branches after feature fusion in the neck network.

[0040] The second input feature map refers to the intermediate feature map that is sent to a specific module (i.e., the frequency gating module) during the feature fusion process in the neck network. It has already undergone partial scale fusion and carries the mixed feature information. For example, this feature map can come from the neck mesoscale fusion branch, and the number of channels can be 512.

[0041] Specifically, the first output feature map is passed to the neck network. The neck network simultaneously receives multiple feature maps from different layers of the backbone network. Through feature pyramid construction methods such as upsampling and downsampling, these feature maps of different resolutions are aligned and fused across scales, allowing high-level semantic information and low-level detailed information to complement each other. After interacting and reorganizing with features from other layers during this fusion process, the first output feature map forms a new feature map on a certain fusion branch, which becomes the second input feature map.

[0042] Step S105: Using the frequency gating module in the neck network, frequency domain residual compensation is performed on the second input feature map to obtain the second output feature map.

[0043] The frequency-gated module, officially known as the Frequency Residual Enhancement Gate (FREG), is a module that performs residual compensation on feature maps through frequency domain analysis. It transforms the features to the frequency domain, suppressing low-frequency background components and extracting high-frequency anomaly information. The second output feature map is the feature map output by the frequency-gated module after performing frequency domain residual compensation on the second input feature map. This feature map supplements the weakened high-frequency details, helping to more stably identify weak trace tampering regions in subsequent detection. Specifically, a frequency-gated module is introduced into the feature fusion path of the neck network. This module first transforms the second input feature map to the frequency domain, using an operation that suppresses low-frequency components while retaining mid-to-high-frequency components to separate the high-frequency residual information carrying tampering traces from the feature map. Then, these high-frequency residuals are transformed back to the original spatial domain and smoothed out through convolution to make them more coherent. Finally, through an adaptive gating mechanism, the network autonomously decides how much to inject these compensation residual information into the original features, thereby obtaining the second output feature map after frequency domain compensation enhancement, making it more robust to post-processing such as compression and scaling.

[0044] Step S106: Perform tampering region detection on the second output feature map to obtain the tampering region detection result corresponding to the chat image.

[0045] The tampering region detection result is the final predicted information output by the tampering detection model, typically presented as a set of bounding boxes with confidence scores. Each box corresponds to a region identified as tampered and its precise location is marked. This result is obtained by predicting the final feature map using a detection head (such as the multi-scale detection head of YOLOv11) and then performing post-processing such as thresholding and non-maximum suppression. Specifically, the second output feature map (along with other relevant feature maps output by the neck network) obtained after the aforementioned feature extraction, directional edge enhancement, multi-scale fusion, and frequency domain residual compensation is fed into the model's detection head. The detection head performs dense predictions at various spatial locations on the feature map, generating a large number of candidate boxes and their corresponding confidence scores to determine whether there are tampering traces within the region. Then, through post-processing steps such as setting confidence thresholds for filtering and suppressing duplicate boxes with excessive overlap, a set of accurate tampering region bounding boxes is finally obtained, which is the tampering region detection result for the chat image.

[0046] The image tampering region detection method provided in this application extracts features through a backbone network and uses its attention module to enhance the directional edges of the feature map. This helps to highlight the boundaries and texture abrupt changes of the tampered region, improving the ability to perceive weak tampering clues. Subsequently, the neck network fuses the enhanced features and introduces a frequency gating module to perform residual compensation on the fused features in the frequency domain. This effectively restores and strengthens high-frequency anomalous information weakened by operations such as compression, and enhances the sensitivity to subtle frequency differences caused by tampering, compensating for the deficiencies of spatial domain processing. This improves the detection stability and localization robustness of the model under post-processing interference such as compression and scaling. Therefore, this application comprehensively enhances feature representation through the synergistic processing of directional edge enhancement and frequency domain residual compensation, achieving accurate detection of tampered regions in chat images, improving the localization effect of weak traces and small-scale tampering, and enhancing the generalization ability across propagation conditions and data distributions.

[0047] This embodiment provides a method for detecting image tampering regions, which can be used in electronic devices such as laptops and desktop computers, and includes the following steps: Step S201: Obtain the chat image to be detected. For details, please refer to [link / reference]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.

[0048] Step S202: Input the chat image into the backbone network of the tamper detection model, and use the backbone network to extract features from the chat image to obtain the first input feature map. For details, please refer to [link to details]. Figure 1Step S102 of the illustrated embodiment will not be described again here.

[0049] Step S203: Using the attention module in the backbone network, the first input feature map is enhanced with directional edges to obtain the first output feature map.

[0050] The internal computational structure of the attention module can be as follows: Figure 3 As shown, Figure 3 This diagram illustrates the structure of the DHIA (High-Frequency Injection Attention) module, showcasing the complete processing chain from the input feature map through channel adaptation, multi-directional high-pass filtering, feature fusion, spatial attention generation, to residual injection output. It should be noted that the symbols X, Y, H, and α in the DHIA module are specific to that module, corresponding to the module input, module output, intermediate high-frequency features, and learnable scalar, respectively. These symbols, along with their counterparts in the subsequent FREG module, are independent symbols within their respective modules, and the specific data objects differ depending on the module.

[0051] Specifically, the attention module includes multiple convolutional kernels with preset directions; it performs directional edge enhancement on the first input feature map to obtain a first output feature map, including: Step a1: Perform channel adaptation on the first input feature map to obtain the first basis features.

[0052] The first input feature map carries the feature information output from the first layer of the backbone network, and is denoted as the input feature map. Its size is ,in For batch size, Input the number of channels. and This represents the height and width of the feature map. For example, the DHIA module can be inserted at layer 3 of the backbone network, with a batch size B of 8. The number of input channels is [value missing]. The target number of output channels for the module can be 256. It can be set to 256. Therefore, channel adaptation is needed to obtain the first basis features from the first input feature map. The specific calculations satisfy the following piecewise relationship:

[0053] If the two are exactly equal, the first input feature map is preserved as is without any transformation; this step is the identity mapping, directly copying the input as the basis feature. If the two are not equal, a 1×1 convolution operation is used to compress or expand the number of channels of the input feature to the target number of channels, accompanied by batch normalization to readjust the feature value distribution to a range suitable for subsequent filtering. In the above exemplary configuration, the number of channels of the first input feature map and the target number of channels of the module are both 256, therefore this step is the identity mapping, i.e. After adaptation, the feature size is After this channel adaptation operation, the output is the first basis feature, which provides a basic feature representation with unified channel dimensions and regular numerical scale for subsequent directional filtering. At the same time, it ensures that the module can be inserted into different layers without being limited by the number of channels. Feature reshaping is completed through linear mapping, providing a unified channel basis for subsequent directional filtering.

[0054] Step a2: Use convolution kernels to perform directional filtering on the first basis features to obtain edge response features in multiple preset directions.

[0055] After the first basis features are prepared, they are filtered using three pre-designed 3×3 fixed-direction high-pass convolution kernels, which are denoted as follows: (level), (vertical), (Diagonal). To avoid excessively large directional filter responses, energy normalization can be performed on each convolutional kernel first. The normalization formula is:

[0056] in, The position index within the convolution kernel is used, and the kernel weights are scaled using the square root of the sum of squares of the kernel elements to ensure that the response energy of the kernels in different directions is of the same order of magnitude. These convolution kernels are constructed as direction-selective high-pass templates. The numerical arrangement within each kernel makes it highly sensitive to pixel value changes in a specific direction. For example, the difference between adjacent pixels on the left and right sides in the horizontal direction is amplified, the difference between adjacent pixels on the top and bottom in the vertical direction is amplified, and the difference between adjacent pixels diagonally opposite in the diagonal direction is amplified. By performing depthwise convolution operations on each channel of the first basis feature with these convolution kernels, the number of groups in the depthwise convolution can be equal to the number of feature channels. For example, 256 channels correspond to 256 groups, obtaining a direction-sensitive high-frequency response without significantly increasing the number of parameters. For the th individual channels, spatial locations The calculation method for the directional high-frequency response is as follows:

[0057] Therefore, we can conclude that:

[0058] That is, the brightness or texture abrupt change components along each direction can be extracted from the original feature map, and the high-frequency response features in three directions can be output, which are denoted as the horizontal response features. Vertical response characteristics Diagonal response characteristics All three dimensions are consistent with the first basis feature. Among these response features, tampered boundaries, splicing gaps, or local texture abrupt changes usually produce stronger activation values, while smooth areas or regular texture areas respond weaker. This achieves initial directional amplification of tampering cues, amplifying tamper-sensitive cues such as boundary discontinuities caused by splicing replacement, repeated edges of local structures caused by copying and moving, and texture abrupt changes caused by removal and filling. This makes it easier for subsequent detection heads to form stable responses on small-scale targets.

[0059] Step a3: Perform convolutional fusion on multiple edge response features to obtain fused edge features.

[0060] After obtaining edge response features from multiple directions, these feature maps each carry complementary directional information (e.g., some emphasize horizontal edges, some vertical edges, and some diagonal edges), and need to be integrated into a unified representation. Specifically, these feature maps from different directions are first concatenated along the channel dimension, and the concatenation operation satisfies:

[0061] For example, with 256 channels in one direction, the number of channels after splicing is 3 × 256 = 768, corresponding to a feature size of... This creates a combined feature tensor with a multiplied number of channels; then, a 1×1 convolution operation is performed on this combined tensor, and batch normalization and SiLU activation function are combined to obtain fused high-frequency features (i.e. fused edge features). The calculation method is as follows:

[0062] in This is the SiLU activation function. This convolution performs linear combination and non-linear activation between channels, learning how to adaptively select and synthesize high-frequency information from different directions at each spatial location. After convolutional fusion, the number of channels can be reduced to a value consistent with the basis features, such as 256, corresponding to a feature size of... It is no longer a simple superposition of responses in a certain direction, but a unified high-frequency representation that is more discriminative of directional information that has been tampered with after network learning and recalibration. It realizes the recalibrated fusion of three-directional responses in the channel dimension, enabling the network to adaptively combine directional information at each spatial location to form a unified high-frequency representation that is more sensitive to tampered boundaries and more suitable for subsequent convolutional learning.

[0063] Step a4: Perform spatial attention calculation on the fused edge features to generate a spatial attention map.

[0064] Fused edge features are feature representations obtained by integrating high-frequency information from different directions. This includes valuable clues such as boundary discontinuities and texture abrupt changes caused by tampering, as well as naturally occurring regular textures and text edges—high-frequency components not caused by tampering. To automatically distinguish between these two types of information, spatial attention computation is needed for this feature. Specifically, the network automatically evaluates the spatial importance of fused edge features through learnable convolutional operations—that is, for each location in the feature map, it learns a scalar score by integrating information from all channels at that location. The higher the score, the greater the probability that the high-frequency information at that location belongs to a genuine tampering trace. Then, through a normalization mapping function, all these scores are uniformly compressed into a fixed value range (e.g., 0 to 1), resulting in a smooth probability weight distribution in the entire feature map in space—this is the spatial attention map. The role of this attention map is not to modify the content of the features themselves, but rather to provide a spatial "enhancement guide" for subsequent feature enhancement operations, indicating which areas should be focused on and enhanced, and which areas can have their responses reduced.

[0065] In some alternative implementations, step a4 above includes: Step a41: Perform channel compression convolution on the fused edge features to obtain intermediate features.

[0066] Step a42: Perform convolution mapping on the intermediate features to obtain the mapped features.

[0067] Step a43: Normalize the mapped features to generate a spatial attention map.

[0068] Perform channel compression convolution on the fused edge features. The channel compression ratio can be, for example, 4:1 (reduction=4), and the minimum number of channels can be set to 4. Perform convolution operation on the multi-channel fused edge features to obtain the intermediate features. The calculation method is as follows:

[0069] For example, when the number of fused feature channels is 256, the number of intermediate feature channels after compression is... It can be 64, corresponding to a feature size of This yields an intermediate feature with a significantly reduced number of channels. This step compresses the information dimensionality while preserving the core spatial distribution pattern. Next, this intermediate feature undergoes another convolutional mapping, using a single convolutional kernel to further compress its channel count to 1, outputting a single-layer two-dimensional mapped feature map. The calculation method is as follows:

[0070] Each pixel value in this image is initially an unnormalized real number, which can be positive or negative, representing the model's initial criterion for determining whether a location belongs to a key region. Then, this mapping feature is normalized by using the Sigmoid function to non-linearly compress each pixel value into the (0,1) interval, thus obtaining the final spatial attention map. :

[0071] Spatial attention map size is The normalized attention map can be directly interpreted as the probability weights by which each spatial location is selected by the model as "needing reinforcement." This suppresses high-frequency interference caused by regular background textures, text edges, etc., allowing reinforcement to focus more on verifiable areas such as splicing edges, boundary discontinuities, and texture anomalies in filled areas. Key areas are represented by the spatial attention map. Labeling and fusion of high-frequency features For a complete feature map, the key is... To depict.

[0072] Step a5: Based on the fused edge features, spatial attention map and first basis features, the first output feature map is obtained.

[0073] The fused edge features provide high-frequency detail information extracted from multiple directions, the spatial attention map identifies the key regions most worthy of enhancement, and the first basis features fully preserve the semantic content of the original features. Combining them into an enhanced output feature map hinges on achieving "selective injection" rather than "global replacement." Specifically, the spatial attention map is first used as a spatial dimension filter to selectively filter information from the fused edge features regionally, highlighting high-frequency responses in key regions and suppressing high-frequency responses in non-key regions, thus forming a spatially filtered correction. Subsequently, a global adjustment factor maintained and learned by the network itself adaptively scales the overall intensity of this correction, allowing the enhancement magnitude to be dynamically adjusted according to the characteristics of different input images, avoiding over-enhancement leading to distortion or under-enhancement resulting in weak effects. Finally, this spatially filtered and intensity-controlled correction is incorporated into the first basis features through compensatory superposition—the information pathways of the basis features themselves are not blocked; the correction only adds additional edge enhancement information. The combined result obtained in this way is the first output feature map. It not only inherits the complete semantic foundation of the original features, but also obtains directional edge enhancement in the areas where tampering may occur, thus achieving a dynamic balance between information supplementation and original fidelity.

[0074] In some optional implementations, the attention module further includes a learnable scalar; step a5 above includes: Step a51: Multiply the fused edge features with the spatial attention map to obtain the weighted edge features.

[0075] Step a52: Multiply the weighted edge features by the learnable scalar to obtain the weighted adjusted features.

[0076] Step a53: Add the weighted adjusted features to the first basis features to obtain the first output feature map.

[0077] In the spatial dimension, each channel of the fused edge feature is multiplied element-wise with the spatial attention map. The weight value of each pixel in the attention map directly scales all channel values ​​at the corresponding position of the fused edge feature, preserving or even highlighting high-frequency responses in high-attention regions while suppressing responses in low-attention regions. This yields the weighted edge feature, which is calculated as follows: ,in This is an element-wise multiplication. At the global scale, this weighted edge feature is multiplied by a learnable scalar parameter. This scalar can be initialized to 1.0 and is a trainable parameter of the network. During training, it is updated along with the other parameters of the network through backpropagation using the loss gradient under the SGD optimizer, controlling the contribution of the entire high-frequency enhancement branch to the final result. The multiplication operation uniformly scales the values ​​of all channels and all positions to obtain the weighted adjusted features. This weighted adjusted feature, which has undergone spatial filtering and global amplitude modulation, is then combined with the first basis features after channel adaptation. Add the corresponding elements together to obtain the first output feature map. The calculation formula is:

[0078] The output feature size is consistent with the first basis feature. The addition operation integrates the enhanced high-frequency information into the basis features, while the residual structure keeps the original information pathway of the basis features unblocked. Even if the high-frequency enhancement has not yet been learned stably in the early stage of training, the network can still approximately maintain the original feature pathway, avoiding performance fluctuations. The addition result is the first output feature map, which will be passed to the next stage of the network for further processing.

[0079] Step S204: Input the first output feature map into the neck network of the tamper detection model, and use the neck network to perform feature fusion on the first output feature map to obtain the second input feature map. For details, please refer to [link to details]. Figure 1 Step S104 of the illustrated embodiment will not be described again here.

[0080] Step S205: Using the frequency gating module in the neck network, frequency domain residual compensation is performed on the second input feature map to obtain the second output feature map.

[0081] The internal calculation structure of the frequency gating module can be as follows: Figure 4 As shown, Figure 4 This diagram illustrates the structure of the FREG frequency residual enhancement gating module, showcasing the complete processing flow from input features through channel alignment, frequency domain transformation, high-pass mask filtering, spatial domain restoration, convolutional shaping, to the gating residual output. It should be noted that the symbols X, Y, H, ... in the FREG module... These are exclusive designations within this module, corresponding to the module input, module output, intermediate residual features, and learnable gating parameters, respectively. The symbols with the same names as those in the aforementioned DHIA module are independent symbols within their respective modules, and the specific data objects vary depending on the module.

[0082] Specifically, the frequency gating module includes a preset mask; frequency domain residual compensation is performed on the second input feature map to obtain a second output feature map, including: Step b1: Channel alignment is performed on the second input feature map to obtain the second basis features.

[0083] The second input feature map is located on the mesoscale feature fusion branch of the neck network and comes from the upper-layer fusion operation; it is denoted as the input feature. Its size is ,in The number of input channels. For example, the FREG module can be inserted into the mesoscale branch after feature fusion of the neck network, with the number of input channels... It can be 512, the target number of channels for the module. = It can be set to 128. However, its channel count may not match the target channel count set internally by the subsequent frequency gating module. Therefore, channel alignment is required to obtain the second basis feature. Specifically, it satisfies the following segmentation relationship:

[0084] The system determines whether the actual number of input channels is equal to the module's expected number of output channels. If they are equal, they are directly passed identically without any transformation. If they are not equal, a 1×1 convolution kernel is used to map the channels, adjusting the number of input features to the target number of channels. In the above exemplary configuration, the second input feature map has 512 channels, and the module's target number of channels is 128. Therefore, a 1×1 convolution is used to map the channels from 512 to 128, obtaining the second basis feature, which is denoted as... The corresponding feature size is After channel alignment, the output is the second basis feature, which provides a standardized input with uniform channel dimensions for subsequent frequency domain transformation, ensuring that the module can insert fusion branches of different scales without destroying channel consistency.

[0085] Step b2: Perform frequency domain transformation on the second basis feature to obtain the first spectral feature.

[0086] The second basis features are transformed from the spatial domain to the frequency domain. A two-dimensional Fast Fourier Transform (FFT) is then applied to each channel of the second basis features, performing a Discrete Fourier Transform independently. The results are represented by the symbol... Representing a two-dimensional Fourier transform, the first spectral feature... satisfy:

[0087] The pixel values, originally arranged by spatial location (height and width), are mapped to complex spectral values ​​arranged by spatial frequency. Low-frequency components in the spectrum correspond to gently changing regions in the image (such as large smooth backgrounds or gradients), while high-frequency components correspond to regions with dramatic changes (such as edges, textures, noise, and potential tampering traces). The resulting first spectral feature is a complex tensor, where the real and imaginary parts of each frequency point describe the amplitude and phase information of that frequency component, providing the basis for subsequent frequency filtering.

[0088] Step b3: Filter the first spectral feature using a preset mask to obtain the second spectral feature.

[0089] To pre-construct a radial high-pass mask, the frequency domain coordinates can first be normalized to... For each frequency domain coordinate point, calculate its radial distance to the frequency center (zero frequency point). The radius calculation formula is:

[0090] Low-frequency suppression threshold For example, a value of 0.12 can be used. Coordinates with a distance less than this threshold fall within the low-frequency region, so the mask value is set to 0 (indicating suppression). Coordinates with a distance greater than or equal to this threshold fall within the mid-to-high-frequency region, so the mask value is set to 1 (indicating preservation). That is, the mask satisfies:

[0091] in This is an indicator function; it takes a value of 1 when the condition is met and a value of 0 when the condition is not met. Multiplying this preset mask element-wise with the first spectral feature clears the low-frequency spectral components to zero, while preserving the mid-to-high-frequency spectral components as is, yields the high-frequency spectrum (the second spectral feature). :

[0092] In the second spectral feature obtained after multiplication, low-frequency contributions such as smooth background are filtered out, leaving only mid-to-high frequency components related to edges, texture abrupt changes, and tampering traces. This forces the model's attention to focus on the frequency range that is more likely to carry tampering clues at the frequency domain level, and explicitly filters out low frequencies at the feature level, focusing the model's attention on the mid-to-high frequency components that are more likely to carry tampering clues. This allows the model to retain the perception of abnormal details even under conditions such as secondary compression and scaling resampling.

[0093] Step b4: Spatial domain recovery is performed on the second spectral features to obtain spatial domain residual features.

[0094] The second spectral feature is a filtered representation in the frequency domain, describing the distribution of the original feature across different spatial frequency components. However, this frequency domain form cannot be directly fused with the original spatial domain features. Therefore, it needs to be converted back to the spatial domain, i.e., performing an inverse mapping from the frequency domain to the spatial domain, recombining the complex representation organized by frequency components into a two-dimensional signal organized by spatial location. This inverse conversion process reconstructs a feature map in the spatial domain, where the value at each location reflects the energy of the mid-to-high frequency components retained after high-pass filtering. This reconstructed spatial domain feature map is the spatial domain residual feature, which exhibits a high response in areas such as altered edges and abrupt texture changes, while showing a weaker response in smooth background areas, thus clearly characterizing the high-frequency anomaly information extracted from the frequency domain in the spatial domain.

[0095] In some alternative implementations, step b4 above includes: Step b41: Perform an inverse frequency domain transform on the second spectral feature to obtain the inverse transform feature.

[0096] Step b42: Extract the real part of the inverse transform feature to obtain the spatial domain residual feature.

[0097] Performing an inverse frequency domain transform on the second spectral feature, and then recombining each complex frequency component in the frequency domain into a two-dimensional signal in the spatial domain using an inverse fast Fourier transform (IFFT), is denoted as . The process outputs an inverse transform feature with the same spatial dimensions as the original second basis feature, where each pixel value is a complex number. Then, the real part value of each pixel is extracted from this complex feature, discarding the imaginary part, as the real part carries the main energy and information content of the reconstructed signal. The extracted real part matrix is ​​the spatial domain residual feature, denoted as […]. The calculation formula is:

[0098] in, This represents taking the real part of a complex number, with feature size consistent with the second basis feature. It is represented as a real feature map, carrying high-frequency residual information recovered from the frequency domain high-pass filtering to the spatial domain.

[0099] Step b5: Perform convolution processing on the spatial domain residual features to obtain enhanced residual features.

[0100] Spatial domain residual features derived directly from the inverse transformation of the frequency domain may suffer from local discontinuities, isolated noise points, or insufficient spatial structure. To make these residual information more smoothly, coherently, and useful for subsequent tasks, they need to be further shaped and enhanced using lightweight depthwise separable convolutions. Specifically, each channel of the residual feature is independently subjected to a 3×3 depthwise convolution, with the number of groups equal to the number of channels (e.g., 128 groups for 128 channels). This captures and models local high-frequency structural information channel by channel, strengthening spatial contextual relationships and obtaining intermediate features. :

[0101] Then, 1×1 pointwise convolution is used to perform cross-channel linear fusion and recalibration on these channel-wise processed features to obtain intermediate features. :

[0102] By combining batch normalization and the SiLU activation function to introduce necessary nonlinearity and numerical stability, the enhanced high-frequency residual characteristics (enhanced residual characteristics) are finally obtained. :

[0103] in The SiLU activation function is used, and the feature size is consistent with the input residual features. After this series of convolutions, normalizations, and activations, the output enhanced residual features are more spatially regular, more refined in expressing high-frequency anomaly information, reduce isolated noise points caused by frequency domain hard masks, and enhance the learnability of effective tampering clues.

[0104] Step b6: Based on the enhanced residual features and the second basis features, the second output feature map is obtained.

[0105] The enhanced residual features carry high-frequency compensation information extracted from the frequency domain and refined through convolution, while the second basis features retain the original semantic content of this layer. When merging the two into the final output features, the residual information is not simply superimposed in a fixed manner; instead, an adaptive injection mechanism is employed. Specifically, the network dynamically determines the strength and even the direction of the compensation based on its overall judgment of the current input features—it can positively enhance high-frequency information, suppress it as needed, or take any intermediate state. This decision is achieved by a parameter controlled by network training, which transforms the network's internal judgment into an overall adjustment signal for the residual information. Subsequently, this adjustment signal is used to globally control the contribution strength of the enhanced residual features, ensuring that the compensation information undergoes adaptive filtering and scaling before injection. Finally, this adaptively adjusted compensation is incorporated into the second basis features in a supplementary superposition manner, achieving on-demand enhancement without disrupting the original feature pathways. The resulting second output feature map retains the original expression of the second basis features and, under the guidance of the network's autonomous judgment, obtains high-frequency compensation in the frequency domain for weakened tampering traces, thus maintaining a more robust detection capability under different scenarios and distortion conditions.

[0106] In some alternative implementations, the frequency gating module includes learnable gating parameters; step b6 above includes: Step b61 involves activating the learnable gating parameters to obtain the gating coefficients.

[0107] Step b62: Multiply the enhanced residual feature by the gating coefficient to obtain the gating adjustment feature.

[0108] Step b63: Add the gating adjustment feature to the second basis feature to obtain the second output feature map.

[0109] The frequency gating module internally maintains a learnable gating scalar parameter. This parameter can be initialized to 0.0 and is a trainable parameter of the network. During training, it is updated according to the loss gradient through backpropagation under the SGD optimizer. This parameter is similar to the learnable scalar in the DHIA module. Each component operates independently and participates in gradient updates within its respective module. When using them, they are first activated using the hyperbolic tangent function (tanh) to map their original values ​​to the range (-1, 1), thus obtaining the gating coefficients. :

[0110] A positive gating coefficient indicates positive injection into the residual, while a negative value indicates negative correction. The absolute value controls the injection intensity. When initialized to 0, the gating coefficient is approximately zero, and the module initially approximates an identity mapping, ensuring stability during the initial training phase. The values ​​of all positions and channels of the enhanced residual feature are uniformly multiplied by this gating coefficient. This multiplication operation achieves global scaling of the residual information, allowing the network to adaptively determine the magnitude and direction of the enhancement based on the current input, resulting in the gated feature. This gated feature is then added to the second basis feature element-wise to obtain the second output feature map. :

[0111] The feature size is consistent with that of the second basis features. The filtered and adjusted high-frequency compensation information is injected into the original feature path, and the sum is the second output feature map. It retains the original semantic basis of the basis features and gains robust expressive ability against weak trace tampering due to frequency domain residual compensation.

[0112] Step S206: Perform tampering region detection on the second output feature map to obtain the tampering region detection result corresponding to the chat image. For details, please refer to [link to details]. Figure 1 Step S106 of the illustrated embodiment will not be described again here.

[0113] In some optional implementations, the method further includes, before step S201: acquiring multiple sample images of the labeled tampered area; and training the tampering detection model using the multiple sample images to obtain the trained tampering detection model.

[0114] When acquiring sample images, five publicly available image tampering detection datasets can be selected to construct training data sources: CASIAv2, Columbia Uncompressed Image Splicing Detection Evaluation Dataset, COVERAGE, NC2016 (NISTNimble2016), and the RTD dataset. These datasets cover various tampering types, including copying and moving, splicing and replacement, removal and padding, and local resampling, and have different resolutions, compression qualities, shooting devices, and scene content, providing the model with effective tampering priors and general localization capabilities. Since the original dataset format is incompatible with the YOLO model, the multi-source data must first undergo unified cleaning, format conversion, and standardization to generate a labeled format dataset that conforms to the YOLO network requirements. A corresponding dataset.yaml configuration file should be created, and the file paths for the training and validation sets should be written into it.

[0115] The dataset can be partitioned using stratified random sampling. First, the dataset is stratified according to its data source, with each of the five data sources treated as an independent stratum. Then, within each stratum, the data is randomly shuffled using a fixed random seed, and the training, validation, and test sets can be divided in an 8:1:1 ratio. In one exemplary partition, the training set could contain 4898 images, the validation set 612 images, and the test set 613 images. This partitioning method ensures that the proportion of different data sources in each subset remains approximately consistent, avoiding bias caused by an excessively high proportion of a single dataset. This allows the validation results to more accurately reflect the model's generalization ability under multi-source data distributions. Here, distribution consistency mainly refers to the approximately consistent proportion of different data sources in each subset, rather than further forcing stratification based on tampering type, image resolution, or compression quality.

[0116] During training, the `train.py` training file can be configured to uniformly scale or crop training images to a preset input size, such as 960×960, set the batch size to, for example, 8, and the training epochs to, for example, 200. Each sample image in the training set, along with its corresponding tampered region bounding box, is fed into the model for forward computation. The model outputs multi-scale candidate boxes and confidence scores. Then, based on the standard loss function for object detection, the classification branch, regression branch, and confidence branch are jointly optimized. The error between the predicted result and the true annotation is calculated, and the error gradient is backpropagated from the output layer to the input layer layer by layer using the backpropagation algorithm. Finally, the SGD optimizer is used to update all learnable parameters in the network, including convolutional kernel weights, learnable scalars in the DHIA module, and learnable gating parameters in the FREG module. The model iterates through multiple training rounds, performing forward computation, loss calculation, and backward update, gradually converging the model parameters to a state capable of accurately detecting and locating tampered regions. During training, a validation set is used to evaluate model performance, and test set images are used for periodic testing to obtain the training effect at each stage, aiding in determining the convergence state and parameter selection. Finally, the optimal model weight file is saved, which is the trained tamper detection model. Through multi-dataset fusion training, the model learns a universally applicable tamper region detection capability, balancing general image tamper recognition capabilities with practical engineering applications in chat image scenarios.

[0117] To verify the detection performance of this application, a comparative experiment was conducted under the above-described exemplary training configuration and dataset partitioning. , As indicators of detection accuracy, the number of parameters and computational cost (FLOPs) are used as indicators of model complexity. The quantitative results are shown in the table below: Table 1

[0118] Combining the quantitative results and detection visualization results in the table above, it can be seen that under this experimental configuration, after introducing the DHIA and FREG modules based on YOLOv11 in this embodiment, the performance of tamper target detection is steadily improved, and the improvement is mainly reflected in the enhanced ability to locate tamper boundary details and weak trace areas.

[0119] Specifically, the baseline model YOLOv11 It is 0.553. The value is 0.442; after introducing the DHIA module into the backbone network, the model... Increased to 0.57 The accuracy was improved to 0.46, representing increases of 0.017 and 0.018 respectively. These results demonstrate that DHIA, by explicitly extracting high-frequency responses in the horizontal, vertical, and diagonal directions using a three-directional fixed high-pass kernel and combining this with spatial attention for region selection, injects substrate features in a residual manner. This effectively enhances "tamper-sensitive cues" such as edge discontinuities, repeated edges, and texture abrupt changes caused by tampering operations like splicing replacement, copying, moving, and removing / filling, thereby improving the detection head's accuracy in identifying and locating tampered regions.

[0120] Furthermore, by overlaying the FREG module onto DHIA, the model... Increased to 0.581 The value was improved to 0.463, representing increases of 0.028 and 0.021 compared to the baseline, respectively; compared to the model that only incorporates DHIA, Further improve 0.011, The improvement is further increased by 0.003. This result shows that FREG explicitly suppresses low-frequency background and preserves mid-to-high-frequency residuals in the frequency domain. At the same time, it injects high-frequency residual compensation into the fusion features in a stable manner through a gating mechanism, which helps to alleviate the problem of weakening tampering traces caused by post-processing such as compression, recoding and scaling resampling. Thus, it can still maintain better localization robustness under more stringent IoU threshold evaluation.

[0121] Regarding model complexity, all three models have 9.4M parameters, indicating that the introduction of DHIA and FREG did not significantly increase model storage overhead. In terms of computational cost, YOLOv11 has 21.3G FLOPs, DHIA increases to 24.3G FLOPs, and FREG further increases FLOPs to 23.9G. Overall, the computational cost increases only slightly, but this is achieved in exchange for higher detection accuracy. This demonstrates that this application has achieved a good balance between detection performance and computational cost, making it suitable for chat log tampering detection scenarios that require both real-time performance and accuracy.

[0122] To visually demonstrate the differences in detection performance between different models, the visualization of detection results is compared to... Figures 5 to 7 As shown, Figures 5 to 7The detection results are illustrated across three typical scenarios: natural images, document scenes, and invoices / certificates. The detection bounding boxes and corresponding confidence scores of the baseline and improved models are presented. In terms of qualitative detection performance, for natural image scenes, both the baseline and improved models can detect tampering targets, but the improved model's confidence score increases from 0.89 to 0.91. For document scenes such as contract registration certificates, the tampered areas are concentrated on fine-grained targets like seals, with the background containing numerous text edges and regular lines causing interference. The baseline model's confidence score is 0.70, while the improved model's increases to 0.78, validating the effect of spatial attention filtering and frequency domain residual compensation in suppressing non-tampering high-frequency interference and enhancing the ability to focus on key evidence areas. For invoices and electronic certificates, even with scaling and compression leading to detail degradation, the improved model's confidence score increases from 0.82 to 0.85, validating the method's enhancement effect on tampering clues under complex post-processing conditions.

[0123] In summary, the quantitative indicators and qualitative visualization results under the experimental conditions jointly demonstrate that by introducing the DHIA and FREG modules into YOLOv11, this application can effectively improve the accuracy of tamper target detection with almost no increase in the number of parameters, especially in highly compressed and complex background scenarios such as document screenshots and invoices, showing better robustness and application value.

[0124] This embodiment also provides an image tampering region detection device, which is used to implement the above embodiments and preferred embodiments, and will not be repeated as already described. As used below, the term "module" can be a combination of software and / or hardware that implements a predetermined function. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.

[0125] This embodiment provides a device for detecting image tampering areas, such as... Figure 8 As shown, it includes: The first acquisition module 801 is used to acquire the chat image to be detected; Extraction module 802 is used to input the chat image into the backbone network of the tamper detection model, and use the backbone network to extract features from the chat image to obtain the first input feature map; The enhancement module 803 is used to perform directional edge enhancement on the first input feature map using the attention module in the backbone network to obtain the first output feature map; The fusion module 804 is used to input the first output feature map into the neck network of the tamper detection model, and use the neck network to perform feature fusion on the first output feature map to obtain the second input feature map. The compensation module 805 is used to perform frequency domain residual compensation on the second input feature map using the frequency gating module in the neck network to obtain the second output feature map. The detection module 806 is used to detect the tampered region on the second output feature map and obtain the tampered region detection result corresponding to the chat image.

[0126] In some optional implementations, the attention module includes multiple convolutional kernels with preset directions; the enhancement module 803 includes: The adaptation submodule is used to perform channel adaptation on the first input feature map to obtain the first basis features; The first filtering submodule is used to perform directional filtering on the first basis features using convolution kernels to obtain edge response features in multiple preset directions; The fusion submodule is used to perform convolutional fusion on multiple edge response features to obtain fused edge features; The generation submodule is used to perform spatial attention calculation on the fused edge features and generate a spatial attention map. The first determining submodule is used to obtain the first output feature map based on the fused edge features, spatial attention map and first basis features.

[0127] In some alternative implementations, the generation submodule includes: Convolutional units are used to perform channel compression convolution on the fused edge features to obtain intermediate features; The mapping unit is used to perform convolutional mapping on intermediate features to obtain mapped features; The normalization unit is used to normalize the mapped features and generate a spatial attention map.

[0128] In some optional implementations, the attention module further includes a learnable scalar; the first determining submodule includes: The first multiplication unit is used to multiply the fused edge features with the spatial attention map to obtain weighted edge features; The second multiplication unit is used to multiply the weighted edge features with the learnable scalar to obtain the weighted adjusted features; The first addition unit is used to add the weighted adjustment feature to the first basis feature to obtain the first output feature map.

[0129] In some alternative implementations, the frequency gating module includes a preset mask; the compensation module 805 includes: The alignment submodule is used to perform channel alignment on the second input feature map to obtain the second basis features; The transformation submodule is used to perform frequency domain transformation on the second basis features to obtain the first spectral features; The second filtering submodule is used to filter the first spectral features using a preset mask to obtain the second spectral features; The recovery submodule is used to perform spatial domain recovery on the second spectral features to obtain spatial domain residual features; The processing submodule is used to perform convolution processing on the spatial domain residual features to obtain enhanced residual features; The second determination submodule is used to obtain the second output feature map based on the enhanced residual features and the second basis features.

[0130] In some optional implementations, the recovery submodule includes: The inverse transform unit is used to perform an inverse frequency domain transform on the second spectral feature to obtain the inverse transform feature. The extraction unit is used to extract the real part of the inverse transform features to obtain the spatial domain residual features.

[0131] In some alternative implementations, the frequency gating module includes learnable gating parameters; the second determination submodule includes: The activation unit is used to activate the learnable gating parameters to obtain the gating coefficients; The third multiplication unit is used to multiply the enhanced residual feature with the gating coefficient to obtain the gating adjustment feature; The second addition unit is used to add the gating adjustment feature to the second basis feature to obtain the second output feature map.

[0132] In some optional implementations, the image tampering area detection device further includes: The second acquisition module is used to acquire multiple sample images of the labeled tampered areas; The training module is used to train the tamper detection model using multiple sample images to obtain the trained tamper detection model.

[0133] The image tampering region detection device provided in this application embodiment can execute the image tampering region detection method provided in any embodiment of this application, and has the corresponding functional modules and beneficial effects for executing the method. Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.

[0134] Figure 9 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application.

[0135] The following is a detailed reference. Figure 9This diagram illustrates a suitable structural schematic for implementing the electronic device described in the embodiments of this application. The electronic device may include a processor (e.g., a central processing unit, graphics processor, etc.) 901, which can perform various appropriate actions and processes according to a program stored in read-only memory (ROM) 902 or a program loaded from memory 908 into random access memory (RAM) 903. The RAM 903 also stores various programs and data required for the operation of the electronic device. The processor 901, ROM 902, and RAM 903 are interconnected via a bus 904. An input / output (I / O) interface 905 is also connected to the bus 904.

[0136] Typically, the following devices can be connected to I / O interface 905: input devices 906 including, for example, touchscreens, touchpads, keyboards, mice, cameras, microphones, accelerometers, gyroscopes, etc.; output devices 907 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; memory devices 908 including, for example, magnetic tapes, hard disks, etc.; and communication devices 909. Communication device 909 allows electronic devices to exchange data via wireless or wired communication with other devices. Although Figure 9 Electronic devices with various devices are shown, but it should be understood that it is not required to implement or have all of the devices shown, and more or fewer devices may be implemented or have instead.

[0137] Specifically, according to embodiments of this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments of this application include a computer program product comprising a computer program carried on a non-transitory computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device 909, or installed from a memory 908, or installed from a ROM 902. When the computer program is executed by the processor 901, it performs the functions defined in the image tampering region detection method of embodiments of this application.

[0138] Figure 9 The electronic device shown is merely an example and should not impose any limitation on the functionality and scope of use of the embodiments of this application.

[0139] This application also provides a computer-readable storage medium. The methods described in this application can be implemented in hardware or firmware, or implemented as recordable on a storage medium, or implemented as computer code downloaded over a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code. When the software or computer code is accessed and executed by the computer, processor, or hardware, the image tampering area detection method shown in the above embodiments is implemented.

[0140] A portion of this application can be applied as a computer program product, such as computer program instructions, which, when executed by a computer, can invoke or provide the methods and / or technical solutions according to this application through the operation of the computer. Those skilled in the art will understand that the forms in which computer program instructions exist in a computer-readable medium include, but are not limited to, source files, executable files, installation package files, etc. Correspondingly, the ways in which computer program instructions are executed by a computer include, but are not limited to: the computer directly executing the instructions, or the computer compiling the instructions and then executing the corresponding compiled program, or the computer reading and executing the instructions, or the computer reading and installing the instructions and then executing the corresponding installed program. Here, the computer-readable medium can be any available computer-readable storage medium or communication medium accessible to a computer.

[0141] Although embodiments of this application have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of this application, and all such modifications and variations fall within the scope defined by the appended claims.

Claims

1. A method for detecting image tampering regions, characterized in that, The method includes: Obtain the chat image to be detected; The chat image is input into the backbone network of the tamper detection model, and the backbone network is used to extract features from the chat image to obtain the first input feature map; Using the attention module in the backbone network, the first input feature map is enhanced with directional edges to obtain the first output feature map; The first output feature map is input into the neck network of the tamper detection model, and the neck network is used to perform feature fusion on the first output feature map to obtain the second input feature map. The frequency-gating module in the neck network is used to perform frequency domain residual compensation on the second input feature map to obtain the second output feature map; The second output feature map is subjected to tampering region detection to obtain the tampering region detection result corresponding to the chat image.

2. The method according to claim 1, characterized in that, The attention module includes multiple convolutional kernels with preset directions; the step of performing directional edge enhancement on the first input feature map to obtain the first output feature map includes: Channel adaptation is performed on the first input feature map to obtain the first basis features; The first basis features are directionally filtered using the convolution kernel to obtain edge response features in multiple preset directions; Multiple edge response features are convolutionally fused to obtain fused edge features; Spatial attention is calculated on the fused edge features to generate a spatial attention map; The first output feature map is obtained based on the fused edge features, the spatial attention map, and the first basis features.

3. The method according to claim 2, characterized in that, The step of performing spatial attention calculation on the fused edge features to generate a spatial attention map includes: The fused edge features are subjected to channel compression convolution to obtain intermediate features; Perform convolution mapping on the intermediate features to obtain the mapped features; The mapping features are normalized to generate a spatial attention map.

4. The method according to claim 2, characterized in that, The attention module further includes a learnable scalar; the step of obtaining the first output feature map based on the fused edge features, the spatial attention map, and the first basis features includes: The fused edge features are multiplied by the spatial attention map to obtain weighted edge features; Multiply the weighted edge features by the learnable scalar to obtain the weighted adjusted features; The weighted adjusted features are added to the first basis features to obtain the first output feature map.

5. The method according to claim 1, characterized in that, The frequency gating module includes a preset mask; the step of performing frequency domain residual compensation on the second input feature map to obtain the second output feature map includes: Channel alignment is performed on the second input feature map to obtain the second basis features; The second basis feature is transformed in the frequency domain to obtain the first spectral feature; The first spectral feature is filtered using the preset mask to obtain the second spectral feature; Spatial domain recovery is performed on the second spectral feature to obtain the spatial domain residual feature; The spatial domain residual features are convolved to obtain enhanced residual features; Based on the enhanced residual features and the second basis features, the second output feature map is obtained.

6. The method according to claim 5, characterized in that, The step of spatial domain recovery of the second spectral feature to obtain spatial domain residual features includes: Perform an inverse frequency domain transform on the second spectral feature to obtain the inverse transform feature; Extract the real part of the inverse transform feature to obtain the spatial domain residual feature.

7. The method according to claim 5, characterized in that, The frequency gating module includes learnable gating parameters; the step of obtaining the second output feature map based on the enhanced residual features and the second basis features includes: The learnable gating parameters are activated to obtain gating coefficients; Multiplying the enhanced residual feature by the gating coefficient yields the gating adjustment feature; The gating adjustment feature is added to the second basis feature to obtain the second output feature map.

8. The method according to claim 1, characterized in that, Also includes: Obtain multiple sample images of the labeled tampered areas; The tampering detection model is trained using multiple sample images to obtain the trained tampering detection model.

9. A device for detecting image tampering regions, characterized in that, The device includes: The first acquisition module is used to acquire the chat image to be detected; The extraction module is used to input the chat image into the backbone network of the tamper detection model, and use the backbone network to extract features from the chat image to obtain a first input feature map; The enhancement module is used to perform directional edge enhancement on the first input feature map using the attention module in the backbone network to obtain the first output feature map; The fusion module is used to input the first output feature map into the neck network of the tamper detection model, and use the neck network to perform feature fusion on the first output feature map to obtain the second input feature map. The compensation module is used to perform frequency domain residual compensation on the second input feature map using the frequency gating module in the neck network to obtain the second output feature map; The detection module is used to perform tampering region detection on the second output feature map to obtain the tampering region detection result corresponding to the chat image.

10. An electronic device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the image tampering region detection method according to any one of claims 1 to 8.