Skip to content

Commit

Permalink
added readme and minor change in main_train.py
Browse files Browse the repository at this point in the history
  • Loading branch information
akshay772 committed Aug 31, 2019
1 parent 58a8e8a commit 2f9529c
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
39 changes: 39 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,41 @@
# Crack_detection_part_metal_python2
Python 2 implementation for android app development
A python flask app running on local host.
Due to computation limitation, images if trimmed to 512x512 pixels.

## Pre-requisite nstall requirements
`pip install -r requirements.txt`

## Run the program
### Some preprocessing to image
#### Structure of folders :
* Download the dataset from [DataSet](https://drive.google.com/open?id=168I7Gg0AMEZ_ne6mU3wx4puUxMs4TFse) and extract the contents to the folder "YE358311_Fender_apron"
* Dataset Directory containing "normal" and "defect" folders
* dataset ---> "/YE358311_defects/YE358311_Crack_and_Wrinkle_defect/"
* dataset ---> "/YE358311_Healthy/"
* Destination Directory containing "train" and "test" folders
* data ----> train ----> {"normal", "defect"} subfolders
* data ----> test ----> {"normal", "defect"} subfolders

### Training a simple CNN classifier (3 Conv + 1 FC)
* `python2 main_train.py` --- Start the training application server(local)
* `http://127.0.0.1:5000/crack_detection_train` --- Train the model
* `python2 main_predict.py` --- Start the testing application server(local)
* `http://127.0.0.1:5000/crack_detection_test` --- Opens an hmtl to upload the image and predict if Defective or Healthy

## Accuracy Metrics
Validation accuracy and loss
* Training loss : 0.1695
* **Training accuracy** : 97%
* Validation/Test loss : 0.2475
* **Validation/Test accuracy** : 92.4%

## Need for Improvements
* Next commit is to submit an andriod one page app to interact with the python flask API, showing upload, train and test functionality just like the webapp above.
* Image Preprocssing/Data Preparation
* Since cracks are of less area as compared to image and noise, will introduce dropouts to improve accuracy
* Preparing a object extraction module (For removing the rest of noise to improve accuracy)
* Preparing a background color update module (For easy extraction of metal part after grayscale conversion)
* Trainng Improvements
* Using a pretrained model such as VGG16 trained on ImageNet
* Using model ensembles such as CNN+SVM (rbf kernel), Gauss filter+LBP+SVM(rbf kernel) etc that have proved improving accuracy
4 changes: 1 addition & 3 deletions main_train.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from flask import Flask, render_template, request
from werkzeug import secure_filename
from urllib.request import urlopen
from PIL import Image
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D, BatchNormalization
Expand All @@ -10,7 +9,6 @@

import numpy as np
import cv2
import urllib
import webcolors
import time, os
import sys, h5py
Expand Down Expand Up @@ -51,4 +49,4 @@ def train_cnn():


if __name__ == '__main__':
app.run(debug=False)
app.run(debug=True)

0 comments on commit 2f9529c

Please sign in to comment.