NI Classification Training Interface Tutorial

NI Classification Training Interface

NI Classification Training Interface Tutorial

Through the Classification Training Interface you can train a classifier file by manually classifying sample images into new or existing classes. Based on those samples, the classifier file can then classify unknown samples into a known class. This tutorial explains how to train and test a classifier file using a set of example images.

This tutorial includes the following sections:

  1. Opening the Example Images
  2. Creating the Bolt Class
  3. Testing the Bolt Classifier
  4. Creating the Motor Class
  5. Testing the Motor Classifier
  6. Editing the Classifier File
  7. Saving the Classifier File

Opening the Example Images

Complete the following steps to open the set of example images in the NI Classification Training Interface:

  1. Launch the Classification Training Interface.
  2. Select File»Open Images.
  3. Complete one of the following sets of steps to select the tutorial images:
    • NI Vision and Vision Assistant
      1. Navigate to <Vision>\Images\Classification Tutorial, where <Vision> is the location to which you installed the NI Vision Development Module.
      2. Select the following images:
        Tip  You can select multiple image files by pressing the <Ctrl> key and clicking each file. Enable the Select all files checkbox to open all listed images in the directory you specified.
        • Parts00.png
        • Parts01.png
        • Bolt00.png
        • Bolt01.png
        • Motor00.png
        • Motor01.png
      3. Click Open.
    • Vision Builder AI
      1. Navigate to <Vision Builder AI>\DemoImg\Classification, where <Vision Builder AI> is the location to which you installed Vision Builder AI.
      2. Select the following images:
        Tip  You can select multiple image files by pressing the <Ctrl> key and clicking each file. Enable the Select all files checkbox to open all listed images in the directory you specified.
        • Parts00.png
        • Parts01.png
        • Bolt00.png
        • Bolt01.png
        • Motor00.png
        • Motor01.png
      3. Click Open.

Creating the Bolt Class

Complete the following steps to create the bolt class and train the bolt classifier:

  1. Use the navigation buttons to locate Parts00.png.
  2. Set the correct options in the Preprocessing tab.
    1. For the Method of thresholding, select Clustering.
    2. Select Dark Objects from the Look For drop-down menu.
  3. Draw an ROI around the bolt in the image.
    Tip  It may be necessary to include parts of other objects in the ROI you draw around the bolt to successfully contain the entire bolt in the ROI. To configure the classification engine to classify the sample of the bolt correctly even though the ROI contains part of another object, enable the Reject Objects Touching ROI checkbox on the Preprocessing tab.

    The NI Classification Training Interface displays the objects in the ROI according to the preprocessing settings. When the preprocessing settings are configured to use a clustering method of thresholding and to look for dark objects, the objects in the ROI are blue.

  4. Select Add New Label from the Class Label list. Enter Bolt for the New Label.
  5. Click OK.
  6. Navigate to the Parts01.png file.
  7. Draw an ROI around a bolt in the image.

  8. Check that the Class Label control reads Bolt and click Add Sample.
  9. Select the Classify tab, and click Train Classifier.

Testing the Bolt Classifier

Complete the following steps to verify that you have trained the bolt classifier:

  1. Select the Classify tab.
  2. Navigate to the Bolt00.png file.
  3. Draw an ROI around the bolt in the image.

  4. Verify that the object in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Bolt. The Classification Score is 1000 because you have defined only one class.
  5. Navigate to the Bolt01.png file.
  6. Draw an ROI around the bolt in the image.

  7. Verify that the sample in the ROI is classified correctly by checking that the Assigned Class Label indicator reads Bolt.

Creating the Motor Class

Complete the following steps to create the motor class and train the motor classifier:

  1. Use the navigation buttons to locate Parts00.png.
  2. Set the correct options in the Preprocessing tab.
    1. For the Method of thresholding, select Clustering.
    2. Select Dark Objects from the Look For drop-down menu.
  3. Draw an ROI around a motor in the image.
    Tip  It may be necessary to include parts of other objects in the ROI you draw around the motor to successfully contain the entire motor in the ROI. To configure the classification engine to classify the sample of the motor correctly even though the ROI contains part of another object, enable the Reject Objects Touching ROI checkbox on the Preprocessing tab.

    The NI Classification Training Interface displays the objects in the ROI according to the preprocessing settings. When the preprocessing settings are configured to use a clustering method of thresholding and to look for dark objects, the objects in the ROI are blue.

  4. Select the Add Samples tab.
  5. Select Add New Label from the Class Label list. Enter motor for the New Label.
  6. Click OK.
  7. Navigate to the Parts01.png file.
  8. Draw an ROI around a motor in the image.

  9. Check that the Class Label control reads motor and click Add Sample.
  10. Select the Classify tab, and click Train Classifier.

Testing the Motor Classifier

Complete the following steps to verify that you have trained the motor classifier:

  1. Select the Classify tab.
  2. Navigate to the motor00.png file.
  3. Draw an ROI around the motor in the image.

  4. Verify that the object in the ROI is classified correctly by checking that the Assigned Class Label indicator reads motor.
  5. Navigate to the motor01.png file.
  6. Draw an ROI around the motor in the image.

  7. Verify that the sample in the ROI is classified correctly by checking that the Assigned Class Label indicator reads motor.

Editing the Classifier File

Use the Edit Classifier tab to view the thumbnail images and descriptive information about the samples classified.

The following list describes the function of each control in the Edit Classifier tab:

  • Classifier File Description—To add a description of the classifier file, select the Classifier File Description textbox and type the description.
  • Relabel—To relabel a sample, select a sample in the browser and click Relabel. If you relabel a sample you must retrain the classifier.
  • Delete—To delete a sample, select a sample in the browser and click Delete. If you delete a sample you must retrain the classifier.
  • Browser Display—The browser can display either all samples or only samples of a specified class.
    • To display all samples, click the All Trained Samples option button.
    • To display samples of a certain class, click the Samples of Class option button and select the class you want to display from the list. The Samples indicator displays the number of samples from that class.
  • The Class Population histogram displays existing classes and the number of samples for each class. The Total # of Samples indicator displays the number of samples you have identified for all classes.

Saving the Classifier File

Now that you have classified several objects, you are ready to save the classifier file. Each classifier file contains the current state of the classification engine options as well as the samples you have trained.

  1. Use the navigation buttons to scroll through the images you classified in this tutorial. Review each image, and check that the class to which the image belongs is correct. When you hover your mouse over the thumbnail image in the Edit Classifier tab, the class name appears in the lower right corner below the image window.
  2. Relabel any images that are not correctly labeled by selecting the image from the browser and clicking Relabel. The Relabel Sample dialog opens. Type the correct label for the image in the New Label control.
  3. Delete any unwanted images by selecting the image in the browser and clicking Delete.
  4. Select File»Save Classifier File.
  5. Enter Tutorial.clf in File Name for the classifier file, and then click Save.