# A Cloud-Based Ambulance Detection System Using YOLOv8 for Minimizing Ambulance Response Time
## 3 System Architecture
### YOLOv8 Model  
The You Only Look Once (YOLO) model was originally derived from the human visual system [28]. As the human system can glance at an image and instantly know what objects are in it, the model performs the same in stages. The YOLO model had a vast amount of support and was made by Ultralytics, although YOLO models are well known to the community of computer vision. The previous versions of YOLO started with the founders of the YOLO model [28]. From there, [PERSON] and [PERSON] improved the YOLO  
Figure 1: Ambulance detection system architecture. to YOLOv2 or YOLO9000 [29]. The reason for calling it YOLO9000 is that it can detect more than 9000 object categories. They also incorporate batch normalization, anchor boxes to improve detection accuracy, and dimension clusters for visualizing the 9000 objects. Then, further improvements were made to the YOLOv3 performance by implementing a new, improved network architecture from Darknet-19 that was used in YOLOv2 and was called Darknet-53 [30]. In YOLOv4 [31], the focus was on incorporating a mosaic data augmentation, which further boosts the model's performance by making it robust to where the objects may appear. And in YOLOv6 [32], a different approach was taken, where they took YOLOv5 for further optimization at the industry levels, which was made by [PERSON] [33]. YOLOv7 introduced a new strategy for training that further boosts the performance of the model [34]. To support a variety of vision tasks, including object identification, segmentation, pose estimation, tracking, and classification, YOLOv8 uses a backbone similar to that of YOLOv5 with a few changes to the CSP Layer, now known as the C2f module. In this work, we choose to use the YOLOv8n (nano) based on the scale of our study. In order to detect ambulance vehicles, the YOLO model divides the image into an \(S\times S\) grid, and for each cell, there is a probability. These probabilities are calculated for each cell, and if the ambulance vehicle falls in one of these cells, every cell of that ambulance vehicle is responsible for a small part of the predicted value. Figure 2 illustrates how the \(S\times S\) grid is configured and how the ambulance vehicle is detected. The YOLO model consists of several functions including the localization loss function, the confidence loss function, and the classification loss function. Multiple sum-squared errors make up the localization loss function. The bounding box predictions are given more weight in the localization loss function by setting \(\lambda\) to 5 and the boxes devoid of ambulances are given less weight by setting \(\lambda_{\Delta}\) to 0.5 in the confidence loss function. Equation (1) offers further information about the YOLO model functions. Figure 2: Ambulance vehicle detection in an \(S\times S\) grid. \[\lambda \sum_{n=0}^{S^{2}}\sum_{k=0}^{B}1_{nk}^{\alpha}\Big{[}(x_{n}-\widehat{x }_{n})^{2}+(y_{n}-\widehat{y}_{n})^{2}\Big{]}\] \[+\lambda\sum_{n=0}^{S^{2}}\sum_{k=0}^{B}1_{nk}^{\alpha}\bigg{[}( \sqrt{w_{n}}-\sqrt{\widehat{w}_{n}})^{2}+\bigg{(}\sqrt{h_{n}}-\sqrt{\widehat{ h}_{n}}\Big{)}^{2}\bigg{]}\] \[+\sum_{n=0}^{S^{2}}\sum_{k=0}^{B}1_{nk}^{\alpha}\bigg{[}\left( \Theta_{n}-\widehat{\Theta}_{n}\right)^{2}\bigg{]} \tag{1}\] \[+\lambda_{\Delta}\sum_{n=0}^{S^{2}}\sum_{k=0}^{B}1_{nk}^{\Delta} \bigg{[}\left(\Theta_{n}-\widehat{\Theta}_{n}\right)^{2}\bigg{]}\] \[+\sum_{n=0}^{S^{2}}1_{n}^{\alpha}\sum_{c\in\gamma}\Big{[}(\rho_{n }(c)-\widehat{\rho}_{n}(c))^{2}\Big{]}\]  
As we can see in Equation (1), the first two lines represent the localization loss function. \(\lambda\) denotes the coefficient that multiplies the loss for the coordinates in each grid cell \(\sum_{n=0}^{S^{2}}\) (i.e., in the \(S\times S\) (\(S^{2}\)) grid) and in each grid box \(\sum_{k=0}^{B}\) where an ambulance can be found, denoted as \(\alpha\). \(1_{nk}^{\alpha}\) represents the identity function, set to 1 if there is an ambulance in the \(n^{th}\) cell, and the \(k^{th}\) bounding box is responsible for the prediction of an ambulance (i.e., object).