/CNN-RoadClassification

Road types classifier, developed using Convolutional Neural Networks in Keras.

Primary LanguageJupyter Notebook

CNN_RoadClassification

General info

The goal of the project was to develop a tool that will be classified the road types based on their images, using Convolutional Neural Networks. Roads were split into four classes:

  1. asphalt road,
  2. cobblestones road,
  3. paved road,
  4. unpaved road.

Technologies

Generic badge Generic badge Generic badge Generic badge Generic badge

Setup

To run the project, check if you have installed all necessary extension. If you want to use the whole dataset you should download it and put into "data/processed" directory . If you only want to see how the model works, you could use samples from data/samples. I strongly recommend using use_example.ipynb sheet, where you can find all necessary function calls with description. This allows you to friendly use of the project files.

Database

Due to pandemic, an only limited database was collected via Google Street View API (original plan was to gather in real roads photos):

  • class 1 (asphalt road) 210 photos,
  • class 2 (cobblestones road) 204 photos,
  • class 3 (paved road) 200 photos,
  • class 4 (unpaved road) 200 photos.

Database for class 3 and 4 contain many photos of the same roads in different places and angles, which was a significant issue during learning. The database is available on Google Drive.

CNN

Architecture of CNN, generated by Netron is show below:

alt text

The file which contained the CNN model is available in "model" directory as Keras ".h5" file. Apart from architecture, some other functionalities from Keras were used:

  • L2 regularization on dense layers with rate = 0.001.
  • Data Augmentation.
  • Changing initializator in convolutional layers to "Kaiming initializer" which is called "he_uniform" in Keras API (based on this article).
  • Early Stopping feature with patience equal to 2 epochs.

Results

CNN created from scratch achieved 84,8% accuracy on the test dataset.

Repository content

src contains all code from this project separated into two folders:

  • processing:
    • load_data.py
  • modeling:
    • training.py
    • evaluating.py

Additionally I made a use_example.ipynb sheet, where you can find all necessary function calls with description. This allows you to friendly use of project files.