# Diagnosis of Pressure Ulcer Stage Using On-Device AI
## 3 Results  
### Pressure Ulcer Detection Performance  
Five trained YOLOv8 models predicted both the class (stage 1-4, DTPI, unstageable) and the regions of pressure ulcers. Table 4 shows a comparison of the overall object detection performance of the five trained YOLOv8 models using the test dataset. To compare the object detection performance, five metrics were calculated: accuracy, precision, recall, F1 score, and mean average precision (mAP). Accuracy, precision, recall, and F1 score are the most common classification evaluation metrics [42]. Accuracy is the proportion of correctly classified objects:  
\[\text{Accuracy}= \frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+\text{ FN}} \tag{1}\]  
TP, TN, FP, and FN denote the number of true positives, true negatives, false positives, and false negatives of each label, respectively. Precision denotes the ratio of the number of positives which are correctly classified (TP) to all positive predictions (TP + FP):  
\[\text{Precision}= \frac{\text{TP}}{\text{TP}+\text{FP}} \tag{2}\] \begin{table}
\begin{tabular}{c c c c c c c} \hline \hline
**Model** & **Accuracy** & **Precision** & **Recall** & **F1 Score** & **mAP@50** & **mAP@50-95** \\ \hline YOLOv8n & 0.810 & 0.910 & 0.870 & 0.889 & 0.898 & 0.674 \\ \hline YOLOv8s & 0.814 & 0.922 & 0.845 & 0.882 & 0.891 & 0.670 \\ \hline YOLOv8m & 0.846 & 0.897 & 0.891 & 0.894 & 0.908 & 0.685 \\ \hline YOLOv8l & 0.789 & 0.895 & 0.861 & 0.878 & 0.892 & 0.671 \\ \hline YOLOv8x & 0.796 & 0.905 & 0.859 & 0.881 & 0.900 & 0.680 \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Overall object detection performance for the test dataset according to YOLOv8 models (8n–8x). Recall is defined as the rate of true positives (TP) among all actual positives (TP + FN):  
\[\text{Recall}= \frac{\text{TP}}{\text{TP}+\text{TN}} \tag{3}\]  
F1 score represents the harmonic mean of precision and recall considering both FP and TN in balance:  
\[\text{F1 score}=2\times\frac{\text{Precision}\;\times\;\text{Recall}}{\text{ Precision}+\text{Recall}} \tag{4}\]  
mAP is defined as follows: mAP is a standard metric to comprehensively examine the performance of the multi-class object detection model [34; 35]. AP is the area under the precision-recall graph for each class and mAP computes AP values and is averaged over all classes:  
\[\text{mAP}=\frac{1}{\text{N}}\underset{\text{i=1}}{\overset{\text{N}}{\sum}} \text{AP}_{\text{i}} \tag{5}\]  
where N is the total number of classes and AP\({}_{\text{i}}\) represents the AP for a given class i. Here, mAP@50 is the mean of the AP values calculated at Intersection of Union (IoU) > 0.5, mAP@50-95 indicates the average of the mAP values computed with altering IoU thresholds ranging from 0.5 to 0.95. IoU is defined as the overlap ratio between the predicted bounding box and the ground-truth object region:  
\[\text{IoU}=\frac{\text{Predicted bounding box}\cap\text{Ground}-\text{truth region}}{\text{Predicted bounding box}\cup\text{Ground}-\text{truth region}} \tag{6}\]  
Among the five tested YOLOv8 models, the YOLOv8m model recorded the highest values except for the precision metric (Table 4). The YOLOv8m model showed strong performance in terms of the overall accuracy of 0.846, recall of 0.891, and mAP@50 of 0.908 on the test dataset. This implies that the YOLOv8m model can classify and detect pressure ulcers with high confidence. Accordingly, the YOLOv8m model was chosen as the best option for diagnosing pressure ulcer stage and it was deployed in mobile devices. Figure 2 demonstrates the values of box loss (box_loss), class loss (cls_loss), and distribution focal loss (dfl_loss) at each epoch during the YOLOv8m model training process. The box_loss measures the difference between estimated bounding box and ground-truth bounding box coordinates. The cls_loss calculates the error in the probabilities of the predicted class compared to the ground-truth class. The dfl_loss offers more informative and accurate estimation of the bounding box.