{'fraction_non_alphanumeric': 0.03167671500733257, 'fraction_numerical': 0.0115691706045299, 'mean_word_length': 4.8932206644901095, 'pattern_counts': {'":': 0, '<': 0, '<?xml version=': 0, '>': 0, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
Predicting Driver Self-Reported Stress by Analyzing the Road Scene

Several studies have shown the relevance of biosignals in driver stress recognition. In this work, we examine something important that has been less frequently explored: We develop methods to test if the visual driving scene can be used to estimate a drivers' subjective stress levels. For this purpose, we use the AffectiveROAD video recordings and their corresponding stress labels, a continuous human-driver-provided stress metric. We use the common class discretization for stress, dividing its continuous values into three classes: low, medium, and high. We design and evaluate three computer vision modeling approaches to classify the driver's stress levels: (1) object presence features, where features are computed using automatic scene segmentation; (2) end-to-end image classification; and (3) end-to-end video classification. All three approaches show promising results, suggesting that it is possible to approximate the drivers' subjective stress from the information found in the visual scene. We observe that the video classification, which processes the temporal information integrated with the visual information, obtains the highest accuracy of $0.72$, compared to a random baseline accuracy of $0.33$ when tested on a set of nine drivers.


I. INTRODUCTION
Understanding how the driving scene impacts the driver's emotional state has found a growing interest in the field of driver-assistance technologies. External driving conditions influence the driver's affective state [1]- [5], impacting both road safety [4], [6] and driver experience [7]. While some specific case studies show that the drivers' stress correlates to road traffic conditions [8]- [11] and road type (city, highway, and parking) [10], [12]- [14], automatically inferring these, possibly causal, relations directly from the driving scene has not yet been explored in-depth.
In this paper, we study how the drivers' subjective stress level can be estimated from images displaying the driving scene. Our study takes inspiration from Healey and Picard's original study on driver stress [12], which constructed low, medium and high stress conditions corresponding respectively to sitting in a parked car with eyes closed, driving on a highway under optimal conditions (dry pavement, no traffic or construction, and good weather), and city driving in a busy area. The authors also measured the complexity of events minute-by-minute under each condition (e.g. a turn, a pothole, or a pedestrian are example events that increased the complexity). Measurements of stress-related physiology and selfreported stress agreed with the low, medium, and high-stress levels as well as correlated with the human-rated assessment of the scene complexity. Based on these observations and recent research [15], our hypothesis is that some objects and events that are visible in the driving scene are informative enough to approximate the current drivers' subjective stress level.
More concretely, the goal is to empirically test with different supervised machine learning approaches, whether the drivers' subjective stress can be inferred solely from real driving scenes extracted from the AffectiveROAD dataset [16]. The dataset contains a collection of real driving videos taken by a camera frontally pointing to the road labelled with the drivers "stress" signals.
The provided "stress" signals were constructed in real-time by an observer who sat in the rear seat and annotated the driving scene "complexity", and validated post-experience by the driver [14]. Fig. 1.a illustrates the data used in our study, while Fig. 1.b illustrates the inference of drivers' subjective stress level on new unseen driving scene videos. The three modelling approaches differ in complexity and technique. First, we used classical machine learning (Random Forest and Support Vector Machines) on 66 handcrafted features encoding the presence of common objects, such as cars, road, traffic signals, or pedestrians. The second and third modelling approaches are based on two end-to-end Deep Con-volutional Networks: an image Convolutional Neural Network (CNN) and a video CNN.
We examine the three modelling approaches and we find all perform significantly above chance on the tested task. As expected, the best accuracies are obtained by the video CNN. For the video CNN we also use a CNN explainability technique (GradCam [17], described in Sect.IV-D) to visualize the areas of the input frames that contribute the most to the output of the model. We find that the model puts attention on certain objects and specific configurations of the scene that align with our work hypothesis.
Our study shows promising results on using the driver scene to approximate drivers' stress. Such findings may have practical applications: from intelligent cars able to better assist drivers under stress, to suggesting less stressful routes and helping improve driver safety.

II. RELATED WORK
Detection of driver affective state is relevant for the development of in-vehicle systems that can help improve driving experience [18]. Stress can have a significant negative impact on driving performance, causing traffic violations and crashes [19], [20]. Various scenarios and interventions have been designed to alleviate the "extreme affective states" when detected [21]- [23]. Based on the driver's state taxonomy of Braun et al. [24], these extreme states correspond to dangerous states, while states with medium arousal levels and positive valence are recognized as optimal ones. Different approaches have been used to detect driver's stress and affective states, including physiology, facial expression, self-reports or biosignals [18], [25], [26], but most have focused only on sensing momentary changing signals from the driver. Including contextual parameters, whether internal or environmental [25], is expected to help improve accuracy. Internal context parameters may include personal parameters such as driver mood or personality [6], [7], while environmental parameters typically characterize external factors such as the weather [9], [27], road traffic [8]- [11], and road type [10], [12]- [14]. Our work in this paper focuses on vision-based extraction of environmental context.
Urban settings tend to have higher complexity [28] that may require a higher level of attention which, in turn, requires higher cognitive workload, thus usually increasing driver arousal and stress. Features that represent this complexity, directly extracted from the visual scene, may be used to characterize such external conditions. Thus, tools for scene analysis become increasingly important to assess the driver's affective state. Thanks to recent advances in machine learning [29], [30] with shared real-world datasets [31]- [33], we believe it is now feasible to train an automated system to predict a driving-induced state of stress from a visual scene.
The definition and annotation of driver emotion remains challenging in real-world driving settings. According to a recent survey by Zepf et al. [18], reliable annotations are important to effectively recognize the emotional state of drivers.
The authors identified three main approaches to such annotations based on their survey: self-reports, external annotators, and experimental context. Self reports require the involvement of the participants by usually asking them to report their driving experience (after the drive) according to questionnaires such as: Positive and Negative Affect Scale [34] or Self-Assessment Manikin [35]. This approach is subjective and might induce some biases. The annotation approach based on external annotators can be more reliable; however, it requires time, effort, and extra cost to find, train, and compensate experienced observers.
If it were possible to automatically identify experimental contexts that are reliably associated with stress levels, then it could provide a new method to annotate a driver's likely state. Thus, our work may help not only with predicting driver stress in real-time applications, but also it may help in expanding the utility of other unlabeled data sets for additional research.

III. DATA
The research we develop in this paper is based on the AffectiveROAD dataset [16] which includes gold-standard stress annotations provided by drivers after real-world openroad driving experiences. We describe below the acquisition protocol and the details of the dataset.

A. AffectiveROAD data description
The AffectiveROAD protocol aims to jointly collect, in real driving scenarios, information about the driving environment (in and outside the car), driver's physiological state (for example, electrodermal activity, breathing rate and heart rate) and the driver's contextual "stress" levels.
The protocol is designed to obtain information about typical daily trips in Grand Tunis (with normal traffic conditions) of 31 km in length that take about 85 minutes (including 30 minutes rest). Driving routes (see Fig. 2) are chosen so that drivers alternate between different road types and environments, which may induce different stress levels.
During each drive, an experimenter, who sat in the back seat, annotated in real-time the perceived stress using a laptopbased slider. This resulted in a subjective score [14], ranging from 0 (not stressful) to 1 (extremely stressful), based on the perception of the driving scene "complexity" and the stress level of the driver. See Fig. 3 for an example of the evolution of the subjective score during the driving experiment. The drivers were asked to validate or correct the score after the experiment. Synchronized videos captured both the inside and outside car environments (visualized side by side) and these were synchronized with the stress score and were shown to each driver. These videos and stress scores were embedded in a platform that offered the user the option to change the stress metric values at any point of the experiment. The resulting stress metric will be denoted as the "human-driver-provided stress" in this paper.
The complete dataset provides data for 13 paths completed by 9 drivers in sunny days. Six of the paths were performed by drivers who completed the driving trajectory only once, and seven paths were accomplished by three drivers who repeated the experiments on different days. The complete dataset related to the 13 paths contains 676.3 minutes of video recordings.

B. Data subset used in this study
Although the AffectiveROAD dataset contains various modalities, the work in this paper uses only the human-driverprovided stress metric and the corresponding scene road video recordings, because it provides cleaner labels on the driver's stress than the physiological signals.
The stress metric was obtained as follows.
In Fig. 4, the left plot shows the histogram of the original stress measures provided by the drivers. Note that the stress variability of the original measures was high for all the drives. It ranges between 0 and almost 1. We then minmax normalized the stress metric within each driver, so each person's labels ranged from a minimum of 0 to a maximum of 1 (original min and max value were very close to 0 and 1, respectively, for all the drivers). Based on the 3-modal metric distribution shown in Fig 4 and after consulting the experimenter who generated the continuous metric [14], we constructed three discrete stress classes as follows: low stress class, for stress scores between 0 and 0.4; medium stress class, for scores between 0.4 and 0.75; and high stress class for scores higher than 0.75. In Fig. 4, the right plot shows the number of instances per each of the three stress classes. For illustrative purposes, Fig. 5 shows randomly selected examples of video sequences for the defined low, medium, and high stress categories. Notice that we can already observe some visual differences in these examples. For the low stress category we do not see much traffic, and the video sequences correspond to scenes where the speed is slow. Based on this extracted sample of video sequences, the low stress category includes segments from the Z zone and highway as defined in Fig. 2. For the medium stress category, we observe the road scene corresponding to areas where one can circulate at a higher speed without close vehicles. The frame sequences depicted in the medium section of Fig. 5 correspond mainly to highway segments. Finally, for the high stress category we observe more clutter, buildings,s traffic, and pedestrians. Our expectation is that these types of characteristic patterns that we observe for the different stress measure categories can be captured by a computer vision model attempting to categorize road scene images or video sequences into the corresponding low, medium, or high stress categories. To avoid the habituation effect that could be induced due to the repetition of the experiment and that might affect the perceived stress, in our experiments we only considered the video recordings corresponding to the first drive of each participant. Thus only these first 9 drives were selected and they correspond to the following participants codes: 1.Drv1-1, 2.Drv2-1, 3.Drv3-1, 4.Drv4-1, 5.Drv5-1, 7.Drv6-1, 9.Drv7-1, 10.Drv8-1, and 11.Drv9-1. For video modelling, the original video sequences, taken at 25fps, were reduced to 2fps.

IV. METHODOLOGY
This section describes the different methods we use throughout the paper. First we provide details about the data splits 3.Drv3-1, 4.Drv4-1 11.Drv9-1 used for the training, validation and test sets. Then, we explain how we perform automatic object segmentation of road scene images. Later, we describe the three different approaches we use for the modelling. Finally, we explain the interpretability techniques we use to qualitatively relate urban image patterns and classification scores.

A. Data Splits
All modelling experiments consider a total of 9 data splits, each leaving out one driver as later testing data. Then, among the remaining 8 drivers, the videos of 2 randomly selected drivers are used for the validation set, while the videos of the remaining 6 drivers are used to train. Each of these 9 data splits is denoted by D i , for indexes i corresponding to the experiment ID in the original AffectiveROAD dataset. Notice that with this data-split protocol we evaluate to what extent the modeling of the human-driver-provided stress measure generalizes to unseen drivers. For reproducibility, the validation and testing drivers for each data split are provided in Tab. I (at each data split the remaining 6 drivers are used for training).
The distribution of low, medium, and high stress classes in each of the data splits is, approximately, 12%, 33%, and 55%, respectively. The dataset has a total of almost 110K instances. In our experiments we balanced the three classes by upsampling the training dataset, each class to the class with more examples, and downsampling the validation and test dataset each class to the class with less examples. The resulting test sets are thus all balanced so that a random choice classifier would score 0.33 accuracy on average.

B. Segmentation of urban scenes
To gain understanding about the impact the road scene has on the human-driver-provided stress, we attempt to identify which objects are present in the visual scene and where they are located. For this goal we require to semantically segment each dataset video frame. Semantic segmentation assigns an object category label to each pixel of an input image. We segmented the images using the Inplace-ABN (DeepLabV3+WideResNet-38) implementation [36], already trained with the Mapillary Vistas dataset [37]. Mapillary Vistas dataset is a large-scale diverse street-view image dataset for semantic urban understanding, containing 25k high resolution images with pixel-accurate annotations of 66 semantic urban objects categories. The Mapillary Vistas dataset has a global coverage and very diverse selection of images considering different weather and seasonal conditions, points of view, and camera models. Annotated objects included categories like sky, road, building, sidewalk, person, and car, among others. Some random examples of images and corresponding segmentations are shown in Fig. 6.

C. Modelling Approaches
To predict driver's stress from their video recordings, we use three different modelling approaches. Two of them take as input a single video frame, and the goal is to estimate the stress measure class for the specific time stamp corresponding to the input frame. The third approach considers instead a video sequence of n seconds as input, and the goal is to estimate the stress measure class at the time stamp corresponding to the last input frame. Thus, in the third case, the model is using the current time stamp frame and some previous frames to infer the stress measure class. For a fair comparison, all modelling approaches were trained with the same number of samples. In the case of the second and the third models, we created a dataset of video sequences with length n = 32 seconds. While the third model uses the video sequences, varying the sequence length from 1 to 32 seconds, the second model uses only the last frame from each sequence.
1) Image classification with object presence features: Our first modelling approach encodes the visual information at each time stamp as a 66-dimension feature vector. Each feature corresponds to one of the object categories included in the segmentation model. More concretely, each feature encodes the area occupied by the corresponding object in the image. With this feature vector we train different classifiers to estimate the stress measure category of the corresponding frame. In particular, we trained Random Forest, Linear SVM, and RBF-SVM using the SciKit-learn Python library.
2) End-to-end image classification: Our second approach consists of an end-to-end Convolutional Neural Network (CNN) that takes as input a video frame to infer the humandriver-provided stress measure category corresponding to the same time stamp. In particular, we use a VGG-16 [38], pretrained with Places-365 dataset [32]. Additionally, to add complexity to the model, after the convolutional layers, we added two consecutive fully connected layers (of 512 hidden units) followed each by a dropout layer of 0.5. Lastly, a fully connected layer with 3 hidden units (one per class) was added as a prediction layer, with softmax activation function. At the training phase, which considers the cross-entropy loss, all layers were frozen except the last convolutional block of the VGG-16 and the newly added layers.

3) End-to-end video classification:
Our third approach to model the inference of the human-driver-provided stress measure category is based on Temporal Segment Networks (TSN) [39]. TSN is a video-level framework that was originally proposed for action recognition in videos. TSN aims to model temporal data with segment-based sampling together with an aggregation module called consensus. The extra information provided by the video sequence is important to increase the accuracy of classification tasks in several setting, including ours. Formally, applied to our problem, each input sequence (video recordings of a driving), V , is divided into K segments of equal length S 1 , S 2 , .., S k . Then, each segment S k is represented by its first frame, T k . Let F (T k , W ) represent a CNN with parameters W , which operates on frame T k to produce an individual prediction. Let function G represent the aggregation consensus that combines the outputs obtained for each frame and let function H provide the final classification for input sequence V . Then the set of all T k are directly considered by the TSN as follows: The implementation of the TSN architecture is shown in Fig.  7. For function F we used the VGG-16 as defined in our image end-to-end model (see Sect.IV-C2) and for the consensus module, we used the average. In the training phase, all VGG-16 segments shared the same weights and their training process was equivalent to the one described in Sect.IV-C2.
Other implementation details include: we used RMSprop as the optimizer algorithm to learn the network parameters. The batch size was set to 4 videos and the learning rate parameter was set to 10e-5. All the convolutional networks from the TSN segments were initialized with a VGG16 pretrained with the places-365 dataset. Most of the trainings converged at 10 epochs. For running the experiments, we used a GPU Tesla P100 of 16GB RAM, and 32GB for physical RAM. The approach was programmed in Python, using the Deep Learning framework TensorFlow 2.3.

D. CNN interpretability with Class Activation Maps
Class Activation Mapping (CAM) [40] and related interpretability approaches, such as gradient-weighted CAM (Grad-CAM [17]), are used to visually interpret the output of a CNN. Concretely, CAM heat maps highlight the regions of the image that contributed the most for the classification score for a specific class. While the original formulation of CAM can be just applied to fully convolutional models, GradCAM can be applied even in the presence of fully connected layers after before the output. In this study we use GradCAM to visualize the most informative frame regions for our video CNN Model.

V. EXPERIMENTS
This section presents the conducted experiments. First, we study how the urban scene composition relates to the stress measure and show the results obtained with the three modelling approaches described in Sect. IV. Then we present an interpretability analysis using Class Activation Maps.

A. Stress measure and road scene composition
We start the experimental section by analyzing which objects are over and under-represented on images related to different stress levels. Considering the automatic image segmentation (as described in Sect. IV), we compute the ratio between the average presence of each object in low/medium/high stress images with respect to the average presence of the same object across all images. Results are shown in Fig. 8. Notice that when the object ratio is 1 it means that its presence in the given stress class does not differ from the average presence. Ratios larger or smaller than 1 indicate, respectively, more or less object presence than the average. As we can see, each stress condition could be characterized by the over-representation of between 4 to 5 urban objects.
The parking, fence, crosswalk, and trash can classes are expected to over-represent the low-stress level, since these objects are frequent in the parking lot and Z zone areas. In these settings, the car was either parked before starting the drive, or slowly moving in the Z zone, which is supposed to induce lower stress than more complex settings. On the other hand, according to the findings of [28], one would expect to find the traffic lights and pedestrian among the urban objects characterizing city segments which are supposed to induce a high-stress level. However, for this set of data, both categories over-represent the low-stress level. After a secondary examination of the images corresponding to low-stress level, we noticed two particularities in the AffectiveROAD dataset that explain this observation. First, several pedestrians, sometimes a group of them, are walking around, not necessarily crossing the street, particularly in the Z zone. Second, some of the traffic light poles are short, making them to occupy the majority of the image, leading to an over representation of the traffic light category in the low stress class.
For the medium-stress level, we find those categories that typically define highway driving and related elements, like ramps (entrance or exit road): tunnel, guard rail, bridge, terrain and traffic signs are the main over-represented objects.
For the high-stress level, we find objects like motorcycle and bicycle, rider, banner, big vehicles and miscellaneous. Riders are the persons on motorcycles and bicycles. This explains why the values of the ratio are almost the same for both rider and motorcycle & bicycle categories. Banners were present in the city areas. Miscellaneous includes several object categories present in the videos such as bench, ground animal, mailbox, potholes, catch basin, junction box, among others. This means that multiple visible objects and multiple interacting vehicles coexist in the same scene, as found in congested urban environments.
Overall, the representation of objects found per stress category validates the assumptions used in earlier studies that parking, highway, and city driving conditions are associated with low, medium, and high stress levels, respectively.

B. Modelling experiments
1) Image classification with object presence features: Our first modelling experiments consist of using classical machine learning methods on image features that encode the presence of objects in the image, as described in Sect. IV-C1. Tab. II shows the accuracy obtained in each of the data splits and the corresponding average (see rows 1, 2 and 3). We observe that the accuracy obtained is significantly above chance (which would be 0.33). This effort shows how a simple representation of the visual information can give relevant insights about driver self-reported stress. Notice that these results are supported by the observations reported in Sect. V-A, suggesting that the appearance of particular objects in the driving scene may be a visual signature associated with stress.
2) End-to-end image classification: The results obtained by the end-to-end image CNN approach described in Sect.IV-C2 are shown in Tab. II, row 4. We observe, as expected, that the image CNN approach outperforms the classical ML methods tested before. Interestingly, we can see that the accuracy varies across the different drivers. The lowest accuracies are obtained for the D 1 , D 2 , and D 9 data splits. This can be explained by the fact that some drivers' perceived stress is significantly different from that of others. Notice that D 1 and D 2 involve test data related to two drivers Drv1 and Drv2, respectively. Drv1 repeated the experiment three times and Drv2 repeated the experiment twice. While the annotation by the observer was done in real-time, the validation and correction of the stress metric by the driver was done on different days. The validation session of the first drive could have happened after the second drive for both of these drivers, which might affect their recollection of their stress levels. D 9 considers the data of the participant Drv7 for the testing, and we learned that Drv7 lived in a foreign country for years and may have had a culturally different perception of the rated stress 1 . More data are needed to make general  conclusions about the possible impact of these factors. Figure 9 (a) shows the average confusion matrix for the image CNN model. Examples in the low-stress class that are wrongly classified are confused with medium and high in an even manner. On the contrary, we see that wrongly classified examples in the medium and high classes are rarely confused with the low-stress class. Wrongly classified medium-stress examples are usually classified as high, while wrongly classified high-stress examples are usually classified as medium. Our explanation is that medium-stress and high-stress examples are visually more similar than low-stress examples.
3) End-to-end video classification: We trained different TSN models (see Sect.IV-C3) by considering different video sequences of length n = 1 seconds to n = 32 seconds and K = 8. Results show increments on the accuracy up to a time window of n = 20 seconds, where we obtain the maximum mean accuracy of 0.72. After that point, accuracy steadily decreases as we keep increasing n. Our thinking is that windows too short may not capture enough temporal contextual information, too large may provide too sparse of temporal contextual information while windows, while 20 seconds may be "just right" for discriminating driving events corresponding to varied levels of driver stress. Fig. 9. (b) shows the average confusion matrix computed across all of the test sets. Results and observations are similar to the ones obtained without considering temporal information: The highest confusion happens between medium and high classes. As we would expect, since the video model contains also temporal data, the correct classifications are higher than the ones obtained with the image CNN model.
Finally, Fig. 10 shows CAM visualizations for the video model. Common to all examples, it is interesting to see the general tendency to focus on the central part of the image, the region where the road is located. This fact is of special interest since it is also central for human driving tasks [41] which may explain the fixation of the CNN on objects in that region. Now, comparing the CNN fixation maps obtained for different stress levels, we highlight the increasing complexity of the CAM for images with higher levels of stress. As elaborated in the introduction, increasing complexity within the driving task usually results in higher levels of stress. Our Class Activation Mappings also seem to indicate that the CNN requires more complex analysis to classify a scene as highly stressful. This fact is also compatible with recent findings relating urban safety with scene disorder [28].

VI. CONCLUSIONS
In this paper, we hypothesized that drivers' subjective stress levels might be estimated directly from automated visual analysis of the driving scene. Using the driving scene videos and the corresponding human-driver-provided stress measures of the AffectiveROAD dataset, we trained three different Machine Learning approaches to estimate driver stress from the driving scenes. The best average accuracy across testing sets was obtained using a video CNN, beating a random model of 0.33 and obtaining 0.72 on leave-one-person out test data. While more work is needed to test on larger and more diverse data sets, representing the variety of cultural and individual differences, these results suggest that the automated analysis of environmental context may contribute significantly to inferring driver affective states during real-world driving conditions. ACKNOWLEDGMENT This work was partially supported by the Spanish Ministry of Science, Innovation and Universities, TIN2015-66951-C2-545-2-R and RTI2018-095232-B-C22. CB is supported by a PhD grant from the Universitat Oberta de Catalunya (UOC). We thank the CEA-LinkLab for providing us with the videos and details on the cohort involved in the study.