Skip to content

viktor-platform/yolo-crack-detection-app

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

YOLO CRACK DETECTION APP

This app uses YOLO to automatically detect cracks in images and applies image processing techniques to assess crack width. The entire workflow is packaged inside a VIKTOR web application.

STEP 1 – Upload Image

Users upload an image using a drag-and-drop field. The app displays the uploaded image to confirm the action was successful, as shown below:

Upload Image

STEP 2 – Run AI Model

The image is sent to a YOLO model running locally through a Viktor Worker. The model detects cracks, segments them, and calculates crack widths using skeletonization. The processed result is sent back to the app, as shown below:

Run AI Model

STEP 3 – Measure Crack Widths

The app converts pixel measurements into millimeters using a known reference object in the image. It then plots a histogram to visualize the width distribution, as shown below:

Measure Crack Widths

STEP 4 – Check Against Standards

Crack widths are compared with Eurocode, ACI, and BS standards. A table highlights acceptable and unacceptable values in green and red, making results easy to interpret, as shown below:

Check Standards

How To Set Up YOLO

The following subsection outlines the required dependencies that your Python environment must have.

Requirements

  • Python: Version 3.11 or later.
  • Operating System: Windows.
  • GPU Support (Optional): CUDA-enabled GPU if you wish to use the PyTorch CUDA wheel.

Dependencies and Versions

The project depends on the following packages, you can create a requirements.txt

opencv-python>=4.11.0.86
torch>=2.6.0
torchaudio>=2.6.0
torchvision>=0.21.0
ultralytics>=8.3.102
scikit-image>=0.20.0

If you are using a CUDA-enabled GPU, install PyTorch and related packages from the CUDA-specific index before installing the remaining dependencies:

pip install torch torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/cu118
pip install -r requirements.txt

Download the weights

You can download the model weights by running this in a folder of your preference and in your Python development environment. The folder where the code below will be run should be added in the configuration file of the VIKTOR worker, as shown in the next section.

import os
import urllib.request
from ultralytics import YOLO 

# Define the filename and the URL for the pretrained model
weight_filename = "crack_seg_yolov8n.pt"
pretrained_weights_url = "https://huggingface.co/OpenSistemas/YOLOv8-crack-seg/resolve/main/yolov8n/weights/best.pt"

# Download the model weights if the file does not already exist
if not os.path.exists(weight_filename):
    print("Downloading pretrained crack segmentation model...")
    urllib.request.urlretrieve(pretrained_weights_url, weight_filename)
    print(f"Model downloaded and saved as '{weight_filename}'.")
else:
    print(f"Model file '{weight_filename}' already exists; skipping download.")

# Load the downloaded model
model = YOLO(weight_filename)
print("Pretrained crack segmentation model loaded.")

Set up VIKTOR Worker

The VIKTOR generic worker requires a config.yaml file to be configured for this app to run properly. An example configuration is shown below:

executables:
  run_model:
    path: 'C:\PATH\TO\python.exe'
    arguments:
      - 'run_model.py'
    workingDirectoryPath: 'C:\Path\TO\YOLO\MODEL\WEIGHTS'
maxParallelProcesses: 1

For more information, refer to the official documentation

⚠️ Important Note

This app is a demo showcasing the integration between VIKTOR and AI models such as YOLO. It demonstrates how image analysis and engineering logic can be combined in a single web application. If you plan to use it for real engineering applications, make sure to validate all results based on your own project needs and engineering judgment.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages