Skip to content
/ cv-tsr Public

German speed limit sign recognition and detection using computer vision; tailored for embedded use

Notifications You must be signed in to change notification settings

yNiklas/cv-tsr

Repository files navigation

Real-Time German Speed Sign Recognition And Detection

This repository implements the detection and recognition of German speed limit signs using deep learning techniques. A 2-stage computer vision model recognizes speed limit signs from dashcam images. Therefore, small and quantized models are used to ensure real-time performance on embedded systems.

demo_night.mp4

CV-Model Structure

A pipeline of two models is used to detect and classify speed limit signs:

  1. Detection Model: A YOLOv8n model is used to detect speed limit signs in the dashcam images. This model outputs bounding boxes around detected signs.
  2. Classification Model: A custom CNN model (TensorFlow) is used to classify the detected speed limit signs into their respective categories (e.g., 20 km/h, 30 km/h, etc.).

Detection

The detection model was trained using the GTSDB dataset. The model is trained to detect a single class (speed limit traffic sign) and its bounding box. Images from the GTSDB dataset without traffic signs or other traffic signs are used as negative data.

Training

  1. Download the GTSDB dataset.
  2. Copy all images (*.ppm) into a folder detection/GTSDB/Images.
  3. Copy the gt.txt files into the folder detection/GTSDB.
  4. Run the detection dataset builder.

This builds two YOLO formatted datasets in the folders detection/dataset and detection/small_dataset. Each folder consists of an images and a labels folder. Images are stored in the .jpg format, since YOLO models do not accept .ppm. For each image, the label is either empty (no traffic signs) or contains one or more bounding boxes of class 0 (speed limit sign). The images and labels folders are split into train, and val subfolders (80/20 split).

Dataset Contents Negative Data
dataset Images of all traffic signs from GTSDB (including non-speed-limit signs) Contains only the negative data of GTSDB (images without traffic signs)
small_dataset Images of only speed limit signs from GTSDB (classes 0-8 & 32, see classes.md) Contains images without traffic signs and images with traffics signs of other classes (non-speed-limit signs). Negative data makes up <= 40% of the small_dataset

Recognition

The recognition model was trained using the GTSRB dataset. To keep the model lightweight and efficient, the model recognizes only the following classes:

Id Name
0 Speed-Limit (20 km/h)
1 Speed-Limit (30 km/h)
2 Speed-Limit (50 km/h)
3 Speed-Limit (60 km/h)
4 Speed-Limit (70 km/h)
5 Speed-Limit (80 km/h)
6 End of (80 km/h) Speed-Limit
7 Speed-Limit (100 km/h)
8 Speed-Limit (120 km/h)
32 End of all speed and overtaking limits
43 No sign (negative samples)

Training

  1. Download the GTSRB dataset. It contains one folder per class.
  2. Use the small trainset builder to create a smaller training set focused on speed limit signs. It includes images from non-speed-limit-sign classes as negative data.
  3. Train the model by running the tsr training file. The script automatically creates a validation split of 20%. The script saves the full model and a INT8-quantized TFLite model for embedded devices.

Followings steps are optional and only relevant if you want to visualize the results with test images: 4. Since the GTSRB test set comes without labels, we use the trained model to build the test set labels. Therefore, run the small test set builder. 5. Configure your desired parameters in the visualization script and run it to gain a visual feedback from the trained model.

Optionally, you can inspect a random image of each class with the show examples script.

Inference

The inference can be tested on images or videos using the run_inference.py or run_video_inference scripts. Test images and videos must be provided in supported formats, e.g., .jpg, .png, .mp4.

demo_day_rain.mp4

About

German speed limit sign recognition and detection using computer vision; tailored for embedded use

Resources

Stars

Watchers

Forks

Languages