This repository is tested on Ubuntu 22. To use this repository, please follow these steps:
- Make sure anaconda is installed.
- Clone this repository or download as a zip.
- Make sure your system has Anaconda installed. Open a terminal to the root directory and enter the following command:
conda env create -f environment.ymlThis will create a conda environment with the required libraries. - After the required libraries have been installed, type
conda activate defect_detectionin your terminal to activate the newly created environment.
The dataset used for this project is the NEU Surface Defect Database. The dataset can be downloaded directly from the site, however, an annotation belonging to the training set is erroneously kept in the validation directory. Please execute the following steps to download and organize the dataset.
Enter the following in your terminal.
pip install kaggle
sudo apt-get install unzip
bash download_dataset.sh
The provided notebook can train, validate and visualize, given the dataset is in the correct directory. To train, please uncomment the training block in the notebook.
In this project, we
- Detect the type of defect.
- Build a method of localizing the defects on the images. The localization method depends on the defect-type.
Step 1 consists of fine-tuning a ResNet-18 to detect defect types. The ResNet-18 works reasonably well as shown by the confusion matrix below.
Step 2 is currently under progress. At the time of writing this document, methods for localizing defects have been developed for only 2 of the 6 defect types: patches and scratches.
Steps 1 and 2 for 15 random images from the validation set are shown below.
The boxes in images are generated using the annotations provided by the dataset - they were not determined as a part of this project. The defective regions are shown for the patches and scratches.
Not yet implemented.
Not yet implemented.
The patches are determined using active contours. For simplicity, we use the Chan-Vese active contours from scikit-image.
Not yet implemented.
Not yet implemented.
Given the high-contrast nature of the images, the scratches can be adequately localized by simply using an edge-detector. This work uses the Canny edge detector.

