## 4 Construction and Optimization for the Deepfake Detection Model
### Noise Reduction and De-Artifacting Using the Diffusion Model  
In the realm of image processing, diffusion models stand out as extensively adopted methods for data generation, leveraging the diffusion relationships between pixels in images or videos to uncover the genesis of images. The fundamental concept behind this approach treats the data generation process akin to a Markov chain, transitioning gradually from a complex data distribution to a simpler Gaussian distribution, and then reversing this process to generate new data points, thereby achieving denoising and artifact removal. Traditional image denoising methods, such as those relying on wavelet transforms or conventional low-pass filters, though effective in some scenarios, often falter when dealing with intricate noise and artifacts, struggling to capture high-order correlations between pixels. Hence, this paper introduces deep-learning-based diffusion models to adeptly learn complex diffusion relationships within images, thereby enhancing the efficacy of image processing tasks. The algorithm of the diffusion model is depicted in Figure 8.  
As illustrated in the process flow above, the diffusion process involves gradually introducing noise into the image, as indicated by the process s \(x_{0}\to x_{T}\) in Figure 8. Conversely, the inverse diffusion process, \(x_{T}\to x_{0}\), entails denoising and restoring the image or generating new images. The diffusion model excels in learning the ability to generate high-quality data samples from noise, thus demonstrating outstanding performance in generating diverse, high-fidelity data, and in image denoising and artifact removal. In the diffusion model illustrated in Figure 8, a cosine noise schedule is primarily employed to balance generation efficiency and quality through a 1000-step fully trained sampling strategy. The denoising network, based on a pre-trained U-Net architecture with encoder-decoder structure, simultaneously captures global structural features and local details via multi-scale feature fusion and skip connections during the reverse denoising process. This design optimizes both noise prediction accuracy and generation speed during progressive denoising steps, which was experimentally validated to enhance detection sensitivity and synthetic data fidelity for forgery detection tasks. In image noise reduction, the diffusion model treats the noisy data as the result of a partial backward diffusion process. Through training, it learns effective strategies to reverse this process, thereby achieving denoising. Deartifacting, meanwhile, targets the elimination of unnatural signals or structures introduced during data acquisition and processing. Consequently, the formulation of the diffusion model is articulated below. It delineates forward and reverse processes, representing sequential stages within the diffusion model, with a forward step of the diffusion model presented as follows. Figure 8: Directed graphical modeling diagram for diffusion models. Figure 7: Structure of the convolutional residual module. The forward diffusion steps of the diffusion model are executed through the application of linear transformations and Gaussian noise, as depicted in Equation (10). \[q(x_{t}|x_{t-1})=\mathcal{N}\Big{(}x_{t}z\sqrt{1-\beta_{t}}x_{t-1},\beta_{t}I \Big{)} \tag{10}\]  
In Equation (10), \(\beta_{t}\) denotes the noise scale at each time step, regulating the amount of noise added. I stands for the identity matrix, ensuring isotropic noise. \(\varepsilon\sim\mathcal{N}(0,1)\) signifies Gaussian noise, while \(q(x_{t}|x_{t-1})\) denotes the Gaussian probability distribution transition. Thus, the computation of noise x_t is expressed in Equation (11). \[x_{t}=\sqrt{1-\beta_{t}}x_{t-1}+\sqrt{\beta_{t}}\varepsilon_{t} \tag{11}\]  
The above equation implies that as time t progresses, \(\beta_{t}\) increases gradually until \(x_{t}\) closely approximates Gaussian noise.