Skip to content

Repository files navigation

Car Damage Detection & Price Estimation using Deep Learning and XGBoost

The project integrates a ResNet50 Convolutional Neural Network for multi-label damage detection with an XGBoost regression model for used-car price prediction, producing a final damage-adjusted vehicle valuation.


Overview

This project was developed as part of a university Artificial Intelligence project and demonstrates the integration of Deep Learning and Machine Learning into a complete prediction pipeline.

Rather than solving damage classification or vehicle valuation independently, the system combines both tasks to estimate the market value of damaged vehicles using a single image together with vehicle specifications.


Badges

Python TensorFlow XGBoost Scikit-Learn License: MIT


Quick Start

Clone the repository:

git clone https://github.com/AliwiWalid/Car-Damage-Detection-Price-Estimation.git

cd Car-Damage-Detection-Price-Estimation

Install the required dependencies:

pip install -r requirements.txt

Run the complete prediction pipeline:

python predict_car_final.py

Features

  • Multi-label vehicle damage detection
  • Detection of multiple damage types simultaneously
  • Clean used-car price prediction
  • Final damaged-car price estimation
  • Transfer Learning using ResNet50
  • XGBoost regression for vehicle valuation
  • Command-line interface
  • Automatic model evaluation
  • Performance visualization
  • Portable project using relative file paths

Project Pipeline

               Vehicle Image
                     │
                     ▼
        ResNet50 Damage Detection
                     │
                     ▼
     Damage Probabilities (6 Classes)
                     │
                     ▼
        Damage Reduction Calculation
                     │
                     │
Vehicle Specifications ─────────────► XGBoost Price Prediction
                     │
                     ▼
       Estimated Clean Vehicle Price
                     │
                     ▼
      Final Damaged Vehicle Price

Damage Classes

The damage detection model performs multi-label image classification, meaning that a single image may contain several damage types simultaneously.

The six supported damage categories are:

  • Dent
  • Scratch
  • Crack
  • Glass Shatter
  • Broken Lamp
  • Flat Tire

Datasets

CarDD Dataset

The damage detection model was trained using the CarDD (Car Damage Detection) dataset, containing annotated vehicle images with multiple damage labels.

Dataset split:

  • Training
  • Validation
  • Test

Each image may contain multiple damage classes.

Dataset: CarDD Dataset


Used Car Price Dataset

The price prediction model was trained using a merged dataset containing approximately 99,000 used vehicles from multiple manufacturers.

Brands Included

  • Audi
  • BMW
  • Ford
  • Hyundai
  • Mercedes
  • Skoda
  • Toyota
  • Vauxhall
  • Volkswagen

Categorical Features

  • Brand
  • Model
  • Transmission
  • Fuel Type

Numerical Features

  • Year
  • Mileage
  • Tax
  • MPG
  • Engine Size

Target variable:

  • Vehicle Price (£)

Dataset: Used Car Dataset (Kaggle)

Note: The original datasets are not included in this repository due to their size and licensing restrictions. Download them separately before training the models.


Methodology

1. Vehicle Damage Detection

Architecture

  • ResNet50 (Transfer Learning)

Framework

  • TensorFlow
  • Keras

Configuration

  • Binary Crossentropy Loss
  • Adam Optimizer
  • Sigmoid Output Layer
  • Input Image Size: 224 × 224

Output

Six independent probabilities corresponding to the six damage classes.


2. Vehicle Price Prediction

Model

  • XGBoost Regressor

Framework

  • XGBoost
  • Scikit-Learn

Evaluation Metrics

  • Mean Absolute Error (MAE)
  • Root Mean Squared Error (RMSE)
  • R² Score

Damage Price Adjustment

The final damaged vehicle price is obtained by combining the clean vehicle price predicted by the XGBoost model with the damage probabilities predicted by the ResNet50 model.

The final price is computed as

Final Price = Clean Price × (1 − Damage Reduction)

where

Damage Reduction = Σ (Damage Probability × Damage Weight)

Each detected damage contributes according to a predefined weight. To prevent unrealistic estimates, the total damage reduction is capped at 60% of the predicted clean vehicle price.


Model Performance

Damage Detection

Test Binary Accuracy

87.3%

Per-Class F1 Scores

Damage F1 Score
Dent 0.78
Scratch 0.79
Crack 0.40
Glass Shatter 0.92
Lamp Broken 0.71
Flat Tire 0.84

Vehicle Price Prediction

Metric Value
MAE £1,319
RMSE £1,990
R² Score 0.955

The XGBoost regression model explains approximately 95.5% of the variance in used vehicle prices.


Example Prediction

Vehicle

Brand: BMW
Model: 330i
Year: 2023
Transmission: Automatic
Fuel: Petrol
Mileage: 20,000

Detected Damage

Scratch

Predicted Clean Price

£27,911.83

Damage Reduction

11.74%

Final Estimated Price

£24,636.04

Repository Structure

Car-Damage-Detection-Price-Estimation/
│
├── train_cardd_resnet50.py
├── train_car_price_xgboost.py
├── predict_car_final.py
│
├── results_resnet50/
│   ├── best_cardd_resnet50.keras
│   ├── accuracy_curve.png
│   ├── loss_curve.png
│   ├── classification_report.csv
│   ├── confusion_matrix_multilabel_6x6.png
│   └── ...
│
├── results_xgboost_price/
│   ├── car_price_xgboost_model.pkl
│   ├── feature_importance_top20.png
│   ├── residual_plot.png
│   ├── actual_vs_predicted_price.png
│   └── ...
│
├── requirements.txt
├── LICENSE
└── README.md

Note: Trained model files and evaluation results are generated automatically after running the training scripts.


Running the Project

Train the Damage Detection Model

python train_cardd_resnet50.py

Train the Vehicle Price Prediction Model

python train_car_price_xgboost.py

Run the Complete Prediction Pipeline

python predict_car_final.py

The application requests:

  • Vehicle image
  • Brand
  • Model
  • Year
  • Mileage
  • Transmission
  • Fuel Type
  • Engine Size
  • MPG
  • Tax

The application outputs:

  • Damage probabilities
  • Detected damage classes
  • Estimated clean vehicle price
  • Damage reduction percentage
  • Final estimated damaged vehicle price

Training Environment

The models were developed and tested using:

  • Python 3.11
  • TensorFlow / Keras
  • XGBoost
  • Scikit-Learn
  • NumPy
  • Pandas
  • Matplotlib

Training was performed on an NVIDIA GPU using CUDA acceleration.


Technologies Used

Programming

  • Python

Deep Learning

  • TensorFlow
  • Keras

Machine Learning

  • XGBoost
  • Scikit-Learn

Data Processing

  • NumPy
  • Pandas

Visualization

  • Matplotlib

Future Improvements

  • Vehicle make and model recognition directly from images
  • Automatic damage localization using object detection
  • Damage severity estimation
  • Explainable AI using Grad-CAM
  • Web application using Flask or FastAPI
  • Mobile application integration
  • Real-time inference
  • Cloud deployment

License

This project is licensed under the MIT License. See the LICENSE file for more information.


Author

Walid

Faculty of Engineering in Foreign Languages (FILS)

National University of Science and Technology POLITEHNICA Bucharest

Interests

  • Artificial Intelligence
  • Computer Vision
  • Deep Learning
  • Machine Learning

About

An end-to-end Artificial Intelligence system that combines Computer Vision and Machine Learning to detect vehicle damage from images and estimate the market value of damaged vehicles.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages