/yolo-corrosion-detection

Basic example of how to train and detect rust corrosion with yolo v7.

Primary LanguageJupyter NotebookApache License 2.0Apache-2.0

yolo-corrosion-detection

Basic example of how to train and detect rust corrosion with yolo v7. This code is nothing more than a group of scripts that automate the training and detection tasks using yolo. Actually the folder yolov7 is basically the repository of yolo project found here: https://github.com/WongKinYiu/yolov7

Another thing important to mention is that this project uses a dataset of rust corrosion images from Roboflow. The dataset is automatically downloaded in the first run, and located at yolov7/Rust8-2 folder. The original dataset can be found here: https://universe.roboflow.com/trailrun/datasetnew-n7bra

This content is part of SCICROP-ACADEMY learning series.

Dependencies

  • Python >= 3.8
  • Poetry >= 1.8
  • Git

How to run: Training + Detection (It is easy!)

The first time you run, it will need to download the dataset and train the model. If you do not have a NVIDIA gpu it will take some hours to train the model. Once the model is trained you will able to run the code again and it will find the weights from the previous training, and then it will run the tests with the 10 images located in test_images folder.

git clone https://github.com/Scicrop/yolo-corrosion-detection
cd yolo-corrosion-detection
poetry run python app.py

Detecting with Yolo

poetry run python yolov7/detect.py --weights runs/train/yolov7-corrosion2/weights/best.pt --source /tmp/rust3.mp4 --view-img

Make sure to pass the correct best.pt in --weights parameter, as well as the correct --source parameter path. The source can be images, videos or even urls of live video cameras.

Results

rust-dection-example-low.mp4

rust0 png_screenshot_26 04 2024 rust1 png_screenshot_26 04 2024 rust2 png_screenshot_26 04 2024 rust3 png_screenshot_26 04 2024 rust4 png_screenshot_26 04 2024 rust5 png_screenshot_26 04 2024 rust6 png_screenshot_26 04 2024 rust7 png_screenshot_26 04 2024 rust8 png_screenshot_26 04 2024 rust9 png_screenshot_26 04 2024

Next Steps

If you want to continue learning about AI with computer vision, take a look in this repository: https://github.com/wlsdzyzl/CorrosionDetection in order to learn how to make image classification with resnet and then image segmentation with unet.