## 3 Methodology
### Data Enhancement Based on Diffusion Model
#### 3.2.3 Diffusion Model  
A diffusion model is a kind of generation model, different from Variable Automatic Encoder (VAE), Generic Adversary Network (GAN) and other generation networks. A diffusion model gradually applies noise to the image in the forward phase until the image is damaged and becomes a complete Gaussian noise, and then learns the process of restoring from Gaussian noise to the original image in the reverse phase. The purpose of a diffusion model is to decompose specific data distribution \(p(x)\) and reconstruct data step by step from random noise. Because the intermediate process is stochastic and unstable, the whole process is generated. In addition, reversible random steps ensure extensive fidelity of the model and sample quality. Specifically, in the forward phase, the noise is gradually increased on the original image, and the new image obtained in each step is only related to the results in the previous step until the image becomes pure Gaussian noise. The diffusion process is a Markov process. The reverse phase is a process of continuous noise removal. This is to give Gaussian noise to the original image, and then gradually remove the noise until the original image is finally restored [20]. The schematic diagram of the forward and reverse processes of the diffusion model is shown in Figure 8. More detailed processes will be described later:  
These are the following points about the forward process. We have a sequence of \(T\) variables, where \(x_{0}\)- \(p(x)\) is our observed data and \(x_{1:T}\) are latent variables. we can think of diffusion models as a specific realization of a hierarchical VAE. What sets them apart is a unique inference model, which contains no learnable parameters and is constructed so that the final latent distribution \(q(x_{T})\) converges to a standard gaussian [21]. This \"forward process\" model is defined as follows:  
\[q(x_{t}|x_{t-1})=N\Big{(}x_{T};x_{t-1}\sqrt{1-\beta_{t}},\beta_{t}I\Big{)} \tag{1}\]  
The variables \(\beta_{1}\dots\beta_{T}\) define a fixed variance schedule, chosen such that \(q(x_{T}|x_{0})\approx N(0,I)\). The forward process transforms sample distribution into gaussian noise. The image is transformed according to Gaussian distribution after adding noise. A nice property of the forward process is that we can directly sample from any timestep. Next, parameter transformation and iteration are carried out to obtain a new expression of the formula:  
\[\alpha_{t}=1-\beta_{t} \tag{2}\]  
\[\overline{\alpha_{t}}=\prod_{s=1}^{t}\alpha_{s} \tag{3}\]  
\[q(x_{T}|x_{0})=N\Big{(}\sqrt{\overline{\alpha_{t}}}\,x_{0},(1-\overline{ \alpha_{t}})I\Big{)} \tag{4}\]  
One consequence of this is that we can draw random samples \(t\)-\(\{1\dots T\}\) as part of the training procedure. Another consequence is that we can make additional manipulations to the lower bound to reduce the variance. This proceeds by observing the following result (from Bayes rule):  
\[q(x_{t}|x_{t-1})=\frac{q(x_{t-1}|x_{t})q(x_{t})}{q(x_{t-1})} \tag{5}\]  
Due to the Markov property of the forward process, we have: \(q(x_{t}|x_{t-1})=q(x_{t}|x_{t-1},x_{0})\). Therefore, by conditioning all terms on \(x_{0}\) we arrive at the following expression. \[q(x_{t}|x_{t-1})=\frac{q(x_{t-1}|x_{t},x_{0})q(x_{t}|x_{0})}{q(x_{t-1}|x_{0})} \tag{6}\]  
This is the main framework of the forward process. Now, let us look at the reverse process. Figure 8: Schematic diagram of forward and reverse processes of the diffusion model. The real noise generated by each forward propagation part is recorded as a label. In addition to inference, the forward diffusion process also includes the \"data set construction process\" similar to that used in this mathematical model. When the model is in reverse diffusion, the Gaussian noise generated in the forward diffusion can be predicted and inferred step by step to restore the initial sample data.