# Fiber Sensing in the 6G Era: Vision Transformers for \(\phi\)-OTDR-Based Road-Traffic Monitoring
## 4 Results and Discussion  
Figure 8 presents the training and validation loss and accuracy for MobileNetV2 (Figure 8a,b) and ViT (Figure 8c,d) for vehicle counting. The curves present the average loss and accuracy for \(k=5\), along with the standard deviation across the folds. ViT reaches a smaller validation loss and a higher validation accuracy. Figure 9 shows the training and validation loss and accuracy for MobileNetV2 (Figure 9a,b) and ViT (Figure 9c,d) for average speed estimation. A value of \(k=7\) is used for cross-validation for both speed estimation models. Again, ViT shows reduced validation loss and improved validation accuracy. The figure also emphasizes the superiority of ViT over MobileNetV2 in parameter estimation tasks. Figure 10 depicts the confusion matrices for car counting (Figure 10a,b) and speed estimation (Figure 10c,d) for the MobileNetV2 and ViT models. In the confusion matrices, the true labels from YOLOv8-based detection are placed on the y-axis, while the predicted labels from DL models are shown on the x-axis. The test set for car counting comprises 131 unseen images. Over this test set, the MobileNetV2 model reaches an accuracy of 0.85, while ViT performs slightly better, with an accuracy of 0.87. For speed estimation, MobileNetV2 attains an accuracy of 0.36, compared to 0.50 for ViT on the validation set. Due to highly imbalanced classes in the speed estimation task, no test set was used. Instead, the confusion matrices are generated based on the validation set for the best fold (\(k=7\)). Classes 1, 2, and 12 of the speed dataset are excluded from the cross-validation loop as they lack sufficient samples for training and validation. These classes correspond to speed ranges of 5-9.99 km/h, 10-14.99 km/h, and 60-64.99 km/h, respectively. As the field trial takes place on a campus street, classes with fewer heavy vehicles are dominant. This characteristic should also be commonly encountered in smart cities with local traffic. As expected, ViT takes more time for inference (15.86 ms per image) than MobileNetV2 (2.19 ms per image). These numbers are acceptable for real-time applications as the vehicle transit time is in the order of seconds and the total collection time is in the minute scale. Estimating outlier speeds is a challenge for both algorithms due to the imbalanced dataset. This limitation should also be encountered in practice, following the particularities of each monitored road. Figure 11 illustrates the application of the investigated DL algorithms in a practical scenario of road monitoring. The figure presents the ViT performance for eight days of testing with unseen data, monitored continuously over a 24-h period. The white squares in the figure represent hours when the system was offline due to technical issues. The figure demonstrates the system's ability to estimate traffic using \(\phi\)-OTDR traces, detecting heavy traffic during peak hours and low vehicle counts during the night. Analyzing the distinctive features of specific days reveals interesting patterns. The rise in traffic on 29-30 August can be traced back to a noteworthy campus event, while the dip in traffic on 26-27 September coincides with occurrences impacting campus traffic. The analysis underscores the potential of \(\phi\)-OTDR-based DFOS systems for traffic control in a smart community context. \begin{table}
\begin{tabular}{c c c} \hline \hline
**Parameter** & **Example in Filename** & **Unit** \\ \hline Vehicle quantity & 3 & vehicles \\ Average speed & 28.12015 & [km/h] \\ Fiber length & 1300 m & [m] \\ Collection period & 300 s & [s] \\ Pulse width & 500 ns & [ns] \\ Pulse period & 100 ms & [ms] \\ Collection mode & byte & string \\ Timestamp & Feb-23-2024\_08\_49\_26 & string \\ \hline \hline \end{tabular}
\end{table} 
Table 3: Parameters in dataset filenames. Figure 8: Train and validation loss and accuracy for car counting using MobileNetV2 (**a**,**b**) and vision transformer (**c**,**d**) using \(k=5\) for cross-validation.