# Method for Enhancing AI Accuracy in Pressure Injury Detection Using Real and Synthetic Datasets
## 3 Proposed Method
### Synthetic Data-Generation Model  
Synthetic data generation is essential for addressing imbalances in the PI dataset and improving the generalization performance of the model. We generated synthetic data using a stable diffusion-based generative AI model. The constructed PI dataset consisted of 3399 images, which were insufficient and inconsistently proportioned by class. Therefore, the dataset required for model training needed to be increased.  
The stable diffusion model is a state-of-the-art deep learning generative model that produces high-quality synthetic images by starting from random noise and iteratively refining it through forward and reverse diffusion processes [40]. It primarily employs a U-Net architecture with attention mechanisms, allowing for efficient encoding and decoding of image features across multiple scales. In our study, we utilized this model to augment our dataset with synthetic PI images and address class imbalance issues.  
Figure 3 illustrates the architecture of the stable diffusion model used in our research. In this paper, we propose generating PI images using a stable diffusion model. The proposed model leverages the structural features of Stable Diffusion to perform compression and latent representation transformation from Pixel Space to Latent Space, effectively capturing the complex structures and lesion states of PI images.  
The overall process of the model involves using an Encoder module to compress the input images. Subsequently, it progressively removes noise from the generated latent representations through a diffusion process in Latent Space, producing high-quality reconstructed images. The diffusion process in Latent Space is divided into multiple stages (T stages), with each stage finely adjusting the latent representations. During this process, Self-Attention and Cross Attention modules are employed to learn various patterns and features of the PI images.  
This model incorporates a Conditioning module to ensure that each image can reflect specific PI states (e.g., Stage 1, Stage 3, Deep Tissue). This conditional control module combines with the latent representations in Latent Space to enable the generation of images tailored to specific states. The conditional information guides the direction of image generation throughout the entire diffusion process, allowing for precise image generation corresponding to each lesion stage.  
Due to the characteristics of Stable Diffusion, Skip Connections are used at each diffusion stage to prevent the loss of information from previous stages. Skip Connections play a crucial role in preserving the fine details of the original image during the reconstruction process, enabling the Decoder module to restore high-quality images converted back to Pixel Space. These structural features aid in clearly representing the various stages of PI, thereby enhancing the model's effectiveness in medical image generation and analysis.  
Figure 3: Stable diffusion model architecture.  
First, we performed preprocessing by loading the original images and labels and then resizing the images. After preprocessing, the images were input into the stable diffusion-based generative AI model. The model begins with random noise and iteratively refines it by learning the patterns and features of the original PI images. The training objective is to minimize the difference between the predicted noise and the actual noise, which is expressed by the loss function,  
\[L:=\mathbb{E}_{\epsilon(x),y,\epsilon\sim\mathcal{N}(0,1),t}\Big{[}\|\epsilon -\epsilon_{\theta}(z_{t},t,\tau_{\theta}(y))\|_{2}^{2}\Big{]} \tag{1}\]  
where \(y\) represents the conditional input (e.g., image labels), \(\tau_{\theta}(y)\) is the embedded conditional input, and \(z_{t}\) is the noisy latent representation at time \(t\). This process produces realistic and diverse images that augment the dataset, helping to improve the model's performance by addressing data scarcity and class imbalance issues.  
Table 2 lists the quantities of the real and synthetic data used in our experiments.