Documentation

  • N/A
  • 2.6
  • 08/06/2021
  • Public Content

Industrial Surface Defect Detection

In this tutorial, you'll run the Industrial Surface Defect Detection reference implementation to verify that
Edge Insights for Industrial
was installed successfully and to start getting familiar with its modules and structure. By following this tutorial, you will learn:
  • How to add a new custom/user application to
    Edge Insights for Industrial
  • How to rebuild
    Edge Insights for Industrial
    with this new application
  • How to visualize the results of the custom application
This reference implementation provides an AI-enabled approach to segment defects from an inspection camera.
Industrial Surface Defect Detection is a reference implementation that can be executed as part of the . If you have not installed that package yet, you can download it here and then follow the
Edge Insights for Industrial
installation instructions.
Target System Requirements
  • Ubuntu* 18.04 LTS
  • Intel® Core™ i5 processor or above with 16GB of RAM

How it Works

The application uses the inference engine included in the Intel® Distribution of OpenVINO™ toolkit. The reference implementation shows an example of how segmentation networks can be leveraged in industrial quality inspection applications.
  • Surface inspection video: Sample video that is used to simulate a surface defect inspection camera stream. The video includes different types of surface defects.
  • Inference Module: Ingests the frames from the camera stream and performs inference on each frame to segment defects. The rate at which each frame is detected is also recorded and displayed on the output Visualizer window of the
    Edge Insights for Industrial
    software stack.
All communication between modules occurs over the
Edge Insights for Industrial
Message Bus. This reference implementation is a sample application that can be executed using the established pipeline.

Get Started

The Industrial Surface Defect Detection reference implementation is a plug-and-play application developed for the
Edge Insights for Industrial
package.
This application is a reference implementation of how to deploy an OpenVINO™ optimized segmentation model using the
Edge Insights for Industrial
pipeline and not a production-ready custom commercially deployable industrial surface defect detection tool.
Industrial Surface Defect Detection is a reference implementation that can be executed as part of the . If you have not installed that package yet, you can download it here and then follow the
Edge Insights for Industrial
installation instructions.

Step 1: Add Surface Defect Detection UDF Components

  1. Copy the Industrial Surface Defect Detection UDF file to the
    Edge Insights for Industrial
    UDFs directory:
    # Set Edge Insights for Industrial home path as environment variable EII_HOME=<path_to_install_dir/IEdgeInsights/> # Copy Surface Defect Detection UDF file to the UDFs directory cp -r surface_defect/ $EII_HOME/common/video/udfs/python/.
  2. Modify the VideoIngestion (VI) and VideoAnalytics (VA) configuration files to add Industrial Surface Defect Detection to the IEdgeInsights pipeline:
    We recommend that you make copies of the original
    $EII_HOME/VideoIngestion/config.json
    and
    $EII_HOME/VideoAnalytics/config.json
    files before proceeding. These files needed to be rewritten to modify the pipeline to use the Industrial Surface Defect Detection application files instead of the default PCB demo application.
    1. Make copies of the original VI and VA
      config.json
      files:
      mv $EII_HOME/VideoIngestion/config.json $EII_HOME/VideoIngestion/config.json_original mv $EII_HOME/VideoAnalytics/config.json $EII_HOME/VideoAnalytics/config.json_original
    2. Copy the new VI and VA
      config.json
      files to execute the Industrial Surface Defect Detection application.
      Optionally, edit the
      va_config.json
      to use the inference hardware of choice [CPU/GPU/Myriad/HDDL]. Default is CPU.
      The deep learning model used in the reference implementation is a deep model, and hence would take a few minutes for the initial loading into an accelerator (Myriad/HDDL) memory.
      cp vi_config.json $EII_HOME/VideoIngestion/config.json cp va_config.json $EII_HOME/VideoAnalytics/config.json
    3. Copy the Industrial Surface Defect Detection sample video to simulate camera stream input:
      cp surface_defect.avi $EII_HOME/VideoIngestion/test_videos/.
      Download the DAGM data and convert the Class1-Class6 test images to video
      surface_defect.avi
      with the convert code:
      import cv2 import glob img_path = 'Your/DAGM/TEST/IMAGE/PATH' img_list = glob.glob(img_path + '*.PNG') fourcc = cv2.VideoWriter_fourcc(*'XVID') writer = cv2.VideoWriter('surface_defect.avi', fourcc, 2, (512, 512)) for imgi in img_list: img = cv2.imread(imgi) writer.write(img) writer.release()
  3. Follow the
    Edge Insights for Industrial
    instructions to provision and launch the containers:
    # Configure the IEdgeInsights pipeline to use VideoIngestion, VideoAnalytics, Visualizer & Web Visualizer containers cd $EII_HOME/build/ sudo python3 builder.py -f video-streaming.yml # Provision cd $EII_HOME/build/provision/ sudo ./provision.sh ../docker-compose.yml # Build and run cd $EII_HOME/build/ docker-compose up --build -d # Enable visualizer display xhost +
    The output will look similiar to:

Step 2: Check the Reference Implementation

The
Edge Insights for Industrial
builds the VideoIngestion, VideoAnalytics, Visualizer and WebVisualizer containers. The VideoIngestion container streams the sample video to the VideoAnalytics container that performs segmentation on each frame to detect defects. Once the frame has been segmented, the image is displayed on the Visualizer output window with the segmentation result and inference time.
Execute the following command to ensure all the containers are running without errors:
sudo docker ps
Check for Success
If it was successful, the results will be similar to:
WebVisualizer Output
The sample video has different types of defects that can be monitored using the Web Visualizer:

(Optional) Stop the Vision Pipline

To stop the
Edge Insights for Industrial
software, execute the following command:
cd $EII_HOME/build/ docker-compose down
To revert to the default PCB Demo application, move the VI and VA
config.json
files to the original copies [Step 1.2.a] and rebuild using the instructions in Step 1.3.

(Optional) Standalone Testing

Testing the Industrial Surface Defect Detection reference implementation outside of the
Edge Insights for Industrial
deployment environment requires OpenVINO™ to be installed on the development system. Please follow instructions on the OpenVINO™ website for installation steps for different inference hardware (CPU/Myriad/HDDL). The reference model is training with DAGM dataset Class1~Class6, you can download it here.
To execute the application on the host development system, follow the instructions below:
# Install dependencies pip install opencv-python==4.4.0.42 # Set OpenVINO env variables source /opt/intel/openvino/bin/setupvars.sh -pyver 3.6 # Run inference on single test image python3 defect_segmentation.py \ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --image <path/to/input/test/image> Ex.: python3 surface_defect/defect_segmentation.py \ --model surface_defect/ref/model.xml\ --image sample_data/Class1_0837.png Expected output: Image : ../sample_data/Class1_0837.png INFO:DEFECT_SEGMENTATION:Prediction : 1 INFO:DEFECT_SEGMENTATION:Inference time : 0.0775909423828125 sec *********************************************************** # Run inference on director of test images python3 defect_segmentation.py \ --model <path/to/model/XML/file> \ --label <path/to/labels/txt/file> \ --dir <path/to/dir/of/test/images> Expected output: Image : ../sample_data/Class6_None-Defect.png INFO:DEFECT_SEGMENTATION:Prediction : 0 INFO:DEFECT_SEGMENTATION:Inference time : 0.07543802261352539 sec *********************************************************** Image : ../sample_data/Class4_0836.png INFO:DEFECT_SEGMENTATION:Prediction : 1 INFO:DEFECT_SEGMENTATION:Inference time : 0.03906846046447754 sec *********************************************************** ...

Summary and Next Steps

In this tutorial, you successfully ran the Industrial Surface Defect Detection application and displayed the result using the
Edge Insights for Industrial
Visualizer output.
To get access to the deep learning training algorithm that was used to generate the Surface Defect Detection model, please contact your Intel account manager.
As a next step, see the Weld Porosity Detection tutorial.

Product and Performance Information

1

Performance varies by use, configuration and other factors. Learn more at www.Intel.com/PerformanceIndex.