Logo Lanfrica

IkeKobby/cnn_image_classification

Domain:

environment and energy

Record type:

software
Creator:
Ike
Host:
mini project with image classification of South African road, classifying between roads with potholes and no potholes ## cnn_image_classification Binary image classification (CNN) project based on the included notebook (`cnn_image_classification/CNN_pothole_classification.ipynb`). This repo now includes: - **A reusable Python module** (`cnn_image_classification/`) for loading data, building models, training, and inference. - **CLI scripts** (`scripts/`) so you can train/evaluate/predict without editing the notebook. - The original helper utilities (`cnn_image_classification/cnn_project_preprocess.py`) and the notebook. --- ## What this project does The notebook trains a **binary classifier** on road images (example classes: `pothole` vs `no_pothole`) using: - A small baseline CNN (“TinyVGG”-style) - Transfer learning with **EfficientNetB0** The added module/scripts generalize that workflow to any 2-class image folder dataset. --- ## Dataset layout (required) Your data should be organized like Keras expects: ``` data/ train/ no_pothole/ img001.jpg pothole/ img002.jpg val/ # optional (if missing, we take a split from train/) no_pothole/ pothole/ ``` Notes: - Class names come from subfolder names. - Keras assigns class indices in **sorted order** (e.g. `["no_pothole", "pothole"]`). --- ## Install Create an environment and install dependencies (minimum): ```bash pip install tensorflow numpy ``` Optional (useful for notebooks/plots and the older helper script): ```bash pip install pandas matplotlib scikit-learn ``` --- ## Train (CLI) EfficientNetB0 (default): ```bash python scripts/train.py \ --train-dir data/train \ --val-dir data/val \ --output-dir runs/effnet_run1 ``` Baseline tiny CNN: ```bash python scripts/train.py \ --train-dir data/train \ --val-dir data/val \ --model-type tiny_vgg \ --epochs 4 \ --output-dir runs/tinyvgg_run1 ``` If you don’t have a separate `val/` folder, omit `--val-dir` and a split will be taken from `train/`. ### Output artifacts Each run writes: - `runs/ /model.keras` - `runs/ /metadata.json` (includes `class_names` + …