# Development and Optimization of Deep Learning Models for Weapon Detection in Surveillance Videos
## 4 Results and Discussion  
### Experimentation  
The objective was to train and fine-tune the model to improve the mAP and FPS of the weapon detector by following the training and optimization workflows as shown in Figures 6 and 7. We have trained several models to evaluate and find the best possible model for inference purposes. The training of the models was performed on different computing devices, first on high-performance machines like RTX 2060, RTX 2080 TI, and Tesla T4, and then they were trained and tested on edge computing devices like Jetson Nano and Raspberry pi. The hyperparameters are set at the default setting for all the models to have an unbiased result and are listed in Table 2 below. Different parameters play important roles in Scaled-YOLOv4 such as image resolution, subdivision, intersection over union (IOU), intersection over union normalization, new coordinates, object smoothness, scaling x y, and loss functions. The first step of model training is to provide the dataset to the model and quickly finish the model training to observe and understand the trend, whether the model is improving the mAP and reducing the loss or not. We followed the aforementioned process and first trained the model with different settings mentioned in the previous table for RTX 2060-based Scaled-YOLOv4 optimization process. Default hyperparameter settings along with subdivision and image resolution of 64 and 512 \(\times\) 512, respectively, gave us 85.5% mAP and an average loss of 14.42. After the first training and testing results, we conceived the idea to set the right number of iterations, which came out to be 4800 and 5400 according to our two classes. For the next training, we changed the subdivision to 32 and kept the resolution size the same as in the previous training along with the default hyperparameter setting and found that the mAP changed to 91.2 and the average loss of the model also dropped down to 16.2. Since the last training session gave good mAP, we kept the subdivision to 32 and changed different parameter settings that could help in further improving the mAP and reducing the loss. Some of the parameters recommended by the authors are:  
* Object smoothness = 0,
* Scale x y = 1.05,
* Remove IOU loss,
* Remove IOU normalization. We observed that the mAP reduced to 90.4 while the average loss improved and dropped to near 4. There is a positive change, however, as mAP plays the main role and therefore we moved toward different parameter settings. Now we reset all the settings and only change the resolution of the input image 608 \(\times\) 608 with subdivision 32 and retrain the model. We observed that changing only the resolution improved the mAP to 91.2; however, there is no effect on average loss, which is still high at around 14. In the next step, we increased the number of iterations to 10,000 with the subdivision and resolution the same as the previous of 32 and 606 \(\times\) 608 to check if increasing the iteration can help the model in learning new features; however, mAP reduced to 91.2 but loss slightly reduced so it did not show any major impact on the results. \begin{table}
\begin{tabular}{l l l} \hline \hline
**Sr. No.** & **Hyper Parameter** & **Value** \\ \hline
1 & Learning rate & 0.001 \\
2 & Decay & 0.0005 \\
3 & Momentum & 0.949 \\
4 & Activation Function & Mish \\
5 & Batch Size & 64 \\
6 & Max Batches/Iterations & 6000 \\ \hline \hline \end{tabular}
\end{table} 
Table 2: Scaled-YOLOv4 Default Hyperparameters Settings for Models Training. To observe the effect of changing the resolution, we changed the input resolution to 640 \(\times\) 640 with a subdivision of 64 and retrained the model; however, it negatively impacted the model, reducing mAP to 83.3. It helped us understand that image resolution can be increased to a certain limit; after that it can impact poorly on the model mAP and average loss.