GithubHelp home page GithubHelp logo

kk-study1 / car-damage-detection Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lplenka/car-damage-detection

0.0 0.0 0.0 18.42 MB

Car damage detection from images using Detectron 2.

Python 0.36% Jupyter Notebook 99.64%

car-damage-detection's Introduction

Car-Damage-Detection

Problem Statement

Given a pic of damaged car, find which part is damaged. The parts can be either of rear_bumper, front_bumper, headlamp, door, hood.

Solution Approach

  • At first, it looked like a classification task but it turned out to be more complex. I did some initial analysis of the dataset to understand the problem statement and given (lot of) annotation files (code be found here.)

  • Based on the analysis, I decided to build two image segmentation models. One model to segment the damages which returns the "damage" polygon(s). One model to segment the parts of the car which returns the "parts" polygon(s). Then I can check damage polygons lie inside which "part" polygon and can detect the damaged part. There should be some way to train a single model that does both the tasks, but it can be the second version. Much later, while writing the final inference code I decided to see how far the damage is from different parts and return the part nearest to a damage.

  • I decided to use MaskRCNN for segmentation tasks. The given data format matched the required VGG format. I completed the installation and implemented of custom Dataset() and Config() classes for this problem.

  • Unfortunately, when I started the training in Google Colab, it got stuck at epoch one. Later I found that many have faced similar issues #1781, #1877, #2168 with the library as it is almost obsolete. I tried to solve it for hours both locally and on Google Colab but could not make it work.

  • After a lot of research I decided to use Facebook's detectron2. I wrote code to convert given VGG annotations to COCO annotations (can be found here) since Detectron2 does not work with VGG dataset.

  • Then I tested how Detectron2 works (here and here) before moving to Google Colab for training.

  • After that, I trained two image segmentation models, one for damage segmentation (can be found here) and one for parts segmentation (can be found here.)

  • Due to time constraint I could not spend much time in fine tuning of the models. Though with minimal tweaks the Average Precision scores were not that good but the models' performances in segmetation tasks were decent.

  • In the final inference notebook (can be found here) I load the models and perform inference of sample images. The results were decent. The performance can be improved using data augmentation and transfer learning. I will be working on those next.

Folder Structure

.
├── Initial Analysis
│   ├── pycocotools
│   ├── data_visualize_coco.ipynb
│   ├── dataset_analysis.ipynb
│   ├── detectron_custom_data.ipynb
│   ├── detectron_test.ipynb
├── COCO_dataset
├── dataset
├── via2coco
│       ├── convert.py
│       ├── getArea.py
│       ├── merge.py
├── detectron_damage_train.ipynb
├── detectron_inference.ipynb
├── detectron_multiclass_parts_train.ipynb
├── requirements.txt
├──.gitignore  
└── Readme.md

Installation

  • Install python dependencies using requirements text file.
pip install -r requirements.txt
  • Pytorch and Detectron2, you can install those separately using the following commands or by refering here and here, I used Google Colab for training, so following are the steps to install Pytorch and Detectron:
torch==1.5.1+cu101 
torchvision==0.6.1+cu101 -f https://download.pytorch.org/whl/torch_stable.html
pip install detectron2==0.2 -f https://dl.fbaipublicfiles.com/detectron2/wheels/cu101/torch1.5/index.html
  • Pycocotools to Visualize Coco Dataset can be installed using this instructions provided here.

Link to datasets and Models

Conclusion

  • Current parts segmentation Model confuses between front and rear bumper, probably because of the less data.
  • Center of polygon was mostly different from center of bounding box.
  • Currently, I am using the center of bounding boxes in detect_damage_part function in inference notebook. I will try to use center of polygons instead, which can give better results.

Next Steps

  • Need data augmentation
  • Need transfer learning
  • Modular code
  • Write docstrings for all functions

car-damage-detection's People

Contributors

lplenka avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.