# Towards an Indoor Gunshot Detection and Notification System Using Deep Learning
## 4 Results  
### Gunshot Detection Deep Learning Model Results  
The CNN model, as discussed in Section 3.1.3, is trained and validated simultaneously until the validation loss is smaller than or equal to 0.05, or for 5000 epochs--whichever is reached first. The training and validation batch size is set to 2048. The learning rate and the learning rate decay are set to \(1\times 10^{-6}\) and \(1\times 10^{-7}\), respectively. Graphs illustrating the trends of loss vs. epochs and accuracy vs. epochs for both the training and validation datasets are presented in Figure 6(a) and 6(b), respectively. These plots vividly depict a consistent decline in loss and a corresponding increase in accuracy as the number of epochs progresses. Upon reaching the 1501 epoch mark, the model achieved a validation loss of 0.05 and stopped after 1 h 4 min, and 22 s of training. Remarkably, both the training and validation datasets demonstrated an accuracy of approximately 0.98 after the 1501 epoch training phase. After completing the training and validation phases, the model, comprising a total of 1224 learned parameters (including filters, weights, and biases), was saved in an H5 file. The model's disk size amounted to 62.66 kB. Subsequently, the model underwent  
Figure 7: (**a**) Loss vs. epochs for training and validation datasets; (**b**) accuracy vs. epochs for training and validation datasets. testing using an unseen test set containing 100,500 samples. During this testing phase, the model achieved a loss of 0.0505 and an accuracy of 0.98. Table 2 provides an overview of the loss and accuracy values for the training, validation, and test datasets, highlighting that the model exhibits similar accuracy across all sets, indicating its robust generalization. Figure 8 illustrates the confusion matrix for the test dataset, while Table 3 presents the precision, recall, and f1-scores for the test dataset. The proposed deep learning model achieves an accuracy of 98% and 2% of the data are misclassified. The reason for this 2% misclassification could be that some sounds might be affected by variations in recording conditions, or different speakers, making it challenging for the model to generalize across diverse inputs. The choice of hyperparameters and architecture might not be perfectly suited for some ambiguous sounds, potentially leading to misclassification. The inherent ambiguity in certain sound patterns or overlapping acoustic features can pose difficulties for any model, limiting its accuracy to less than 100%. Thus, achieving 100% accuracy with CNNs is difficult for a large dataset due to these inherent challenges in the data and modelling. approximately 15.5 \(\times\) 12.3 \(\times\) 4 cm, is shown in Figure 8(b). The device is programmed according to the discussion in Section 3.2.1. in Firmware part and is configured to run the programs automatically on boot. On the Jetson Nano device, the average pre-processing time of one recorded sound which includes MFCC generation and normalization is 29 ms, and the inference time by the deep learning H5 model is 212 ms. However, after converting the H5 model to the TRT engine, as discussed in Section 3.1.4, the inference time by the TRT engine is reduced to only 3.9 ms, making the inferencing 54 times faster. The power consumption of different parts and the entire device is measured using the jetson-stats library [73] and shown in Table 4.  
After the device is powered up, the heartbeat LED starts to blink indicating the program is running and listening for sounds. The central server, as discussed in Section 3.2.2, was running on an Internet-connected computer. The system is then configured using the smartphone app--as discussed in Section 3.2.3. Some screenshots of the smartphone app for configuring the emergency responder, the user, and their device are shown in Figure 10. Using the app, a user and a device are added, and the Wi-Fi of the device is configured successfully. In the central server, the user and device information got updated as expected.