Abstract
Deep learning-based perception algorithms have gained importance in autonomous vehicle perception systems in recent years. Since the training data cannot cover all critical scenarios and corner cases, how to ensure the safety and reliability of deep learning-based perception functions in crucial scenarios is still an open challenge. Conventional approaches test the driving functions in real-life environments, which can be risky and uneconomic to validate in corner cases. Virtual scenario-based simulation validation approaches can generate a large number of test cases by setting test scenario parameters, but the purely combinatorial parameter cannot effectively generate corner cases. In this paper, we present a novel approach to generating corner cases in a virtual environment for validation of a CNN (Convolutional Neural Network)-based lane detection function. We represent the scene features with parameters, and then use the deep Q-learning reinforcement learning approach to generate the parameter combinations of corner cases. In addition, by comparing with the approaches of random combination and pairwise combination of scene parameters, our approach can generate corner cases more efficiently and improve the testing efficiency of the autonomous driving perception functions.
Autonomous driving is one of the key topics in research and industry. Through many sensors (e.g. vision sensors, radar, lidar, etc.), self-driving vehicles can recognize their surroundings and identify potential hazards to ensure a safe driving. Since convolutional neural networks can automatically extract features with generalization ability and robustness, it is increasingly used in environment perception functions, especially vision-based environment perception functions in autonomous driving. However, how to effectively test the safety and reliability of deep learning-based perception algorithms, especially in corner cases, is still an open challenge.
Conventional validation methods require the accumulation of a certain number of safe driving miles. According to Lipinsk
Another validation method is the scenario-based validation method. By validating the autonomous driving function in different test scenarios as well as critical scenarios to determine the safety and reliability of the driving functions. For the scenario-based method, a large number of test scenarios can be constructed effectively and reproductively through the combination of scenario parameters
The deep learning algorithms in autonomous driving need to be trained with a large quantity of data. To improve the reliability and safety of deep learning algorithms in real-live driving, more data is needed, especially the data from uncommon scenarios or even dangerous scenarios in the real world. These scenarios or scenes are called corner cases. According to Kowol et al
Scenario-based validation method plays an essential role in the testing of autonomous driving functions in recent years. Scenarios are generally to substantiate test cases for autonomous driving function
The Pegasus projec
Ebne
- Ego-vehicle: defines some parameters of the ego vehicle itself.
- Traffic participants: other vehicles, pedestrians, bicycles, etc.
- Environmental elements: roads, infrastructure, weather, light, and other objects.
The scenario description method provides the basic elements needed to describe the scenario. The scenario elements can be selected to generate the required study scenarios. Then, the scenario extraction method is used to select the hazard scenarios as corner cases.
Ahme
Motivated by the study of Kowo

Fig. 1 CNN-based lane detection
The input is the front-view camera image. The network performs a binary classification of each pixel point of the image to determine whether it belongs to the lane line or the background. The difference between the predicted lane lines and Ground Truth is calculated to determine whether the lane lines are correctly detected. Since the number of lane line pixels is significantly less than the number of background pixels in the road scene, the training data is imbalanced. Dice Los
The recognition target for the lane detection algorithm is the lane marking. Therefore, environmental elements are mainly considered for description of the scene, for example, road curvature, lighting conditions, weather conditions, etc.
In this paper, corner cases are defined as: when the lane detection algorithm cannot correctly recognize the lane line in this scene, then the scene is saved as a corner case. A threshold of the difference between the predicted and the target can be used to determine whether the lane lines are correctly detected.
In this section, the corner cases generation method for the CNN-based lane detection algorithm is presented. The environment parameters are used to describe the scene, and then modeling software is used to transform the scene parameters into virtual camera pictures. The system under test is a CNN-based lane detection algorithm. The test results are analyzed to determine whether the input scenes are corner cases.
The corner case generation process is as follows:
(1) Initialize the environment parameters;
(2) Generate virtual scenes;
(3) Execute the test;
(4) Analyze the test results;
(5) Store the parameters of corner cases.
The environment parameters are first randomly initialized by using a stochastic algorithm to generate the initial scene parameter combinations. The scene parameters are through the API of the scene modeling software as input into the scene modeling software to generate the virtual scene. The front camera pictures of the virtual scene are acquired by the virtual camera.
During the execution of the test, the camera pictures are entered the lane detection network as input data and the lane pixels in the pictures are predicted by the CNN algorithm. The difference between the predicted lane line and the target lane line is analyzed to determine whether the scene is a corner case. In the corner case, the CNN network cannot recognize the lane lines correctly. Therefore, the combination of corner case parameters can be stored on the computer to be subsequently retrained to the network. The performance of the CNN network can be improved.
After storing the parameters of the corner cases, the new combination of parameter can be generated by looping. This is a decision process to decide how to update the parameters and the combination of parameters. So we can take an action to update a scene parameter, and the state after the decision is the virtual world scene, which can be generated after updating the parameter.
How to adopt an effective strategy to update the parameter combination can be solved by using Q-learning reinforcement learning. When the state-action pairs have a large dimensionality, deep Q-learning can be used to approximate the Q-table in Q-learning. Therefore, to improve the testing efficiency as well as to generate the corner cases more efficiently, the deep Q-learning reinforcement learning algorithm was used in our work.
In the above corner cases generation process (4), the test result is the difference between the predicted lane line and the target lane line. Therefore, the scene parameters and the corresponding test results can be used as input to generate the next parameter combination using deep Q-learning reinforcement learning. A corner case generation module based on deep Q-learning can be added after (4) to generate new scene parameters.

Fig. 2 Corner cases generation
where: is the reward when moving from the state to the state ; is the learning rate (); is the discount factor (). The learning rate determines the extent to which the newly acquired information replaces the old information. The discount factor determines the importance of future rewards. The smaller the discount factor, the more short-sighted the Q-learning Agent is, and only cares about the rewards currently available.
The parameter space consisting of environmental parameters in this work is huge, and the corresponding Q-table will be too large to be completely stored in computer memory. Thus, a neural network can be used here to approximate the Q-table.
During the training process of deep Q-learning, states, actions, environmental rewards and the next state can be stored in an experience pool, and then a small batch of experience can be randomly sampled from the experience pool as training data and used to update the estimation of the Q-value. This method of using experience to train a neural network is called Experience Repla
The parameters in fixed Q-targets-Network are generally updated less frequently to avoid Q-value is overestimated or underestimated, which improves the robustness of the algorithm. The network is trained using mean squared error as the loss function.
Corner cases are a challenge for deep Learning algorithms. Generating as many reproducible corner cases as possible can support improving the performance of training and inference. Collecting corner cases in the real world is not an option, because corner cases occur infrequently and are usually dangerous when they occur. For this purpose, we used the autonomous driving simulator CARL

Fig. 3 CARLA virtual scenes
As a case study for the visual detection algorithm, we mainly consider the parameters that have an impact on the camera image, such as Weather, lighting, road condition, and sensor failure are the main influencing factors of camera-based lane detection. Considering the used CARLA (Version 0.9.10) only cloudiness, precipitation, wind intensity, sun azimuth and fog as weather factors can be applied. The cloudiness and wind intensity have less influence on camera-based lane detection. The precipitation in CARLA lacks the distortion caused by raindrops on the windshield compared the real scene. Therefore, we only consider the sun azimuth and fog as weather factors in this case study. Lighting, road condition and sensor failure are adjusted using the parameters in the CARLA API. The following 6 scene parameters and their value ranges are defined in this paper.
- Road curvature: when the road curvature is negative, it is a left-turn road; when the road curvature is equal to 0, it is a straight road; when the road curvature is positive, it is a right-turn road. The value range [-1, 1], where -1 means left turn, 0 means straight ahead, and +1 means right turn.
- Ambient brightness: set by the sun altitude angle in CARLA, its value range is [-90, 90], where -90 is late night, +90 is noon
- Sun azimuth: indicates the azimuth of the sun in the sky in the CARLA world, and its value range is [0, 360°].
- Fog density: weather parameter in CARLA world, indicating the visibility of vehicles, the range of values is [0, 100]. When this parameter is 0, the weather is clear, and the visual distance is unrestricted. In contrast, when this parameter is 100, the visual distance is highly limited, approximately around 10 meters.
- Water on the road: indicates whether there is water on the road surface, the value range is [0, 1], where 0 means the road is dry and 1 means there is visible water on the road.
- Blurring caused by the dirty lens: the value range [0, 1], where 0 means the lens is clean and the screen is normal; 1 means the lens is dirty and the screen is blurred.
Different scenes can be generated by changing the above six parameters and the corresponding combinations of parameters in the process of corner case generation. The agent in deep Q-learning model proposes to change the scene parameter so that different combinations of parameters are created. The agent can make 6 actions with 6 scene parameters. After executing an action, the environment generates a new state and rewards, which is in the CARLA virtual world. The environment rewards are related to the predicted result of the lane detection algorithm. The relation between actions and states can be approximated by a neural network. The agent in Q-learning always chooses the optimal action to get the maximum reward. However, only exploiting the current knowledge may lead to sub-optimal behavior. For the exploration of new options, we apply an epsilon-greedy approach to ensure that the agent has a probability to choose a random action for exploration, instead of always exploiting with prior knowledge.
Metric for corner cases: A threshold can be set to determine whether the lane lines in a scene are correctly detected or not. In this work, we assume that if the dice loss between the predicted and true values is greater than 0.5, the lane lines of the scene will be considered as not correctly recognized.
To test the deep Q-learning corner cases generation approach, we generated 20,000 test scenes. The number of scenes in which lane cannot be accurately recognized is 11148, of which 56% are corner cases.As a comparison, we used two other approaches to generate test scenes:
- Random Testing: 20,000 test scenes were generated using a combination of randomly selected scene parameters. The number of scenes in which the lane cannot be recognized is 4833, accounting for 24%.
- Combination Testin
Therefore, the deep Q-learning reinforcement learning method generates a higher percentage of corner cases. The corner cases generation approach is more effective.

Fig. 4 Comparison of corner cases generated by random testing, combination testing and deep Q-learning
Different scene parameters have different effects on the CNN-based lane detection algorithm.

Fig. 5 Corner cases scene parameter distribution
Some of the generated corner cases are shown in

Fig. 6 Examples for generated corner cases
In this paper, we demonstrate a method to validate CNN-based perception functions through virtual tests and employ deep Q-learning reinforcement learning to generate corner cases. By comparing with the methods of random testing and combination testing, this method can generate corner cases effectively and improve the testing efficiency.
In the future some potential improvements can be explored:
(1) More parameters can be considered to describe the environment and increase the environment details, such as precipitation, snow, the number of lanes, road users, etc.
(2) In this work we mainly analyze the scene in the corner case, and the scenario parameters are independent of time. Future research can be extended to dynamic scenarios, such as scenario parameters changing with time.
(3) Other reinforcement learning methods can be used to analyze the corner case in perception, decision making, and control algorithms in automated driving.
Reference
LIPINSKI D. Wie gut ist genug?—Pegasus Projekt, 2019[EB/OL]. https://www.pegasusprojekt.de/files/tmpl/Pegasus-Abschlussveranstaltung/PEGASUS_Abschlussveranstaltung_Wie_gut_ist_gut_genug.pdf. [Baidu Scholar]
BAUMANN D, PFEFFER R, SAX E. Automatic generation of critical test cases for the development of highly automated driving functions[C]//2021 IEEE 93rd Vehicular Technology Conference (VTC2021-Spring). IEEE, 2021: 1-5. DOI: 10.1109/VTC2021-Spring51267.2021.9448686. [Baidu Scholar]
KOWOL K, BRACKE S, GOTTSCHALK H. A-Eye: Driving with the Eyes of AI for Corner Case Generation[J]. arXiv preprint arXiv,2202:2022.10803. DOI: 10.48550/ARXIV.2202.10803. [Baidu Scholar]
ULBRICH S, MENZEL T, RESCHKA A, et al. Defining and substantiating the terms scene, situation, and scenario for automated driving[C]//2015 IEEE 18th international conference on intelligent transportation systems. IEEE, 2015: 982-988. DOI: 10.1109/ITSC.2015.164. [Baidu Scholar]
PEGASUS. Projekt zur etablierung von generell akzeptierten gütekriterien, werkzeugen und methoden sowie szenarien und situationen zur freigabe hochautomatisierter fahrfunktionen[R]. 2019. https://www.pegasusprojekt.de/files/tmpl/pdf/PEGASUS_Abschlussbericht_Gesamtprojekt.PDF. [Baidu Scholar]
EBNER A. Referenzszenarien als grundlage für die entwicklung und bewertung von systemen der aktiven sicherheit[D]. Berlin:Technischen Universität Berlin, 2014. https://d-nb.info/1067387501/34. [Baidu Scholar]
AHMED M, SALEH K, ABOBAKR A, et al. Scenario generation-based training in simulation: pilot study[C]//2019 IEEE International Conference on Systems, Man and Cybernetics (SMC). IEEE, 2019: 1239-1244. DOI: 0.1109/SMC.2019.8913985. [Baidu Scholar]
SONG Q, TAN K, RUNESON P, et al. Critical scenario identification for realistic testing of autonomous driving systems[J]. 2022. DOI: 10.21203/rs.3.rs-1280095/v1. [Baidu Scholar]
JADON S. A survey of loss functions for semantic segmentation[C]//2020 IEEE Conference on Computational Intelligence in Bioinformatics and Computational Biology (CIBCB). IEEE, 2020: 1-7. DOI: 10.1109/CIBCB48159.2020.9277638. [Baidu Scholar]
WATKINS C J C H, Dayan P. Q-learning[J]. Machine Learning, 1992, 8(3): 279-292. DOI: 10.1007/BF00992698. [Baidu Scholar]
MNIH V, KAVUKCUOGLU K, SILVER D, et al. Playing atari with deep reinforcement learning[J]. arXiv preprint arXiv, 2013:1312.5602. DOI: 10.48550/arXiv.1312.5602. [Baidu Scholar]
DOSOVITSKIY A, ROS G, CODEVILLA F, et al. CARLA: An open urban driving simulator[C]//Conference on robot learning. PMLR, 2017: 1. DOI: 10.48550/arXiv.1711.03938. [Baidu Scholar]
Kuhn D R, Bryce R, Duan F, et al. Combinatorial testing: Theory and practice[J]. Advances in Computers, 2015, 99: 1. [Baidu Scholar]