This repository contains scripts to train an object detection model for the Bosch Future Mobility Challenge (BFMC): https://boschfuturemobility.com/
The model can detect and classify the following:
- Traffic signs: oneway, stop, highway entrance/exit, roundabout, parking, crosswalk, no entry, priority
- Cars
- Pedestrians
It includes tools for annotation, label generation using an existing model, preprocessing, synthetic dataset generation, training, evaluation, and analysis.
Install dependencies:
pip install -r requirements.txt-
Clone the repository
cd ~ git clone https://github.com/simonli357/TrafficObjectDetection.git
-
Download the dataset
Download the bfmc_data.zip from this Google Drive link: click here
-
Unzip and create a symbolic link to the dataset
Linux:
ln -s /path/to/unzipped/dataset ~/TrafficObjectDetection/bfmc_dataWindows (PowerShell):
New-Item -ItemType SymbolicLink -Path "C:\Users\YourUser\TrafficObjectDetection\bfmc_data" -Target "D:\Path\To\Unzipped\Dataset"
-
Generate datasets A and C:
a) Generate augmented cropped images:
python3 preprocessing/apply_augmentations.py
(Tune values in the script to your needs)
b) Resize the images with Gaussian distribution:
python3 preprocessing/resize_normal.py
c) Create dataset A:
python3 preprocessing/create_datasets_a.py
d) Create dataset C:
python3 preprocessing/create_datasets_c.py
-
Combine all datasets into one
python3 preprocessing/combine_datasets.py
-
Train the model
python3 training/train.py
-
Test all epochs and save results
python3 training/test_all_epochs.py
-
Plot results for all epochs
python3 training/plot_all_epochs.py
-
Generate labels for annotation
python3 annotation/generate_labels.py
(Modify the script to point to the images you want to annotate)
-
Adjust labels manually
python3 annotation/correct_labels.py
This will open a GUI window with the image and bounding boxes:
- Move or resize bounding boxes by clicking on them
- Add new box: press
aand draw - Change label class:
0to9→ respective classesi→ class 10o→ class 11p→ class 12
- Save:
s - Navigate:
b(back),n(next) - Crop and save bounding boxes:
c - Hide part of the image:
hand draw a box - Delete image and label:
x - Quit:
q