This approach uses a traditional CNN for crack classification and Grad-CAM for crack localization. The whole procedure can be found in this Medium article.
- Pytorch (>=1.9)
- torchvision (>=0.4)
- cv2
- pil
- matplotlib
We will create class activation maps to highlight the crack location. To create class activation map using the grad-cam method you need to install the package simply by typing:
pip install grad-cam
At first clone this repository and install the required dependencies.
To train the network:
python train.py
An example inference command:
python inference.py
To generate grad-cam visual explanation (heat maps) run the following:
python xai.py
The procedure for using your own dataset is very simple. Just prepare the dataset in the same way shown inside the directory folder data/
. You can also increase the number of classes as you need. All you need to change the final layer of the architecture.