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:
- Opening the Example Images
- Creating the Bolt Class
- Testing the Bolt Classifier
- Creating the Motor Class
- Testing the Motor Classifier
- Editing the Classifier File
- 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:
- Launch the Classification Training Interface.
- Select File»Open Images.
- Complete one of the following sets of steps to select the tutorial images:
- NI Vision and Vision Assistant
- Navigate to <Vision>\Images\Classification Tutorial, where <Vision> is the location to which you installed the NI Vision Development Module.
- 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
- Click Open.
- Vision Builder AI
- Navigate to <Vision Builder AI>\DemoImg\Classification, where <Vision Builder AI> is the location to which you installed Vision Builder AI.
- 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
- Click Open.
- NI Vision and Vision Assistant
Creating the Bolt Class
Complete the following steps to create the bolt class and train the bolt classifier:
- Use the navigation buttons to locate Parts00.png.
- Set the correct options in the Preprocessing tab.
- For the Method of thresholding, select Clustering.
- Select Dark Objects from the Look For drop-down menu.
- 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.
- Select Add New Label from the Class Label list. Enter Bolt for the New Label.
- Click OK.
- Navigate to the Parts01.png file.
Draw an ROI around a bolt in the image.
- Check that the Class Label control reads Bolt and click Add Sample.
- 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:
- Select the Classify tab.
- Navigate to the Bolt00.png file.
- Draw an ROI around the bolt in the image.
- 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.
- Navigate to the Bolt01.png file.
- Draw an ROI around the bolt in the image.
- 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:
- Use the navigation buttons to locate Parts00.png.
- Set the correct options in the Preprocessing tab.
- For the Method of thresholding, select Clustering.
- Select Dark Objects from the Look For drop-down menu.
- 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.
- Select the Add Samples tab.
- Select Add New Label from the Class Label list. Enter motor for the New Label.
- Click OK.
- Navigate to the Parts01.png file.
Draw an ROI around a motor in the image.
- Check that the Class Label control reads motor and click Add Sample.
- 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:
- Select the Classify tab.
- Navigate to the motor00.png file.
- Draw an ROI around the motor in the image.
- Verify that the object in the ROI is classified correctly by checking that the Assigned Class Label indicator reads motor.
- Navigate to the motor01.png file.
- Draw an ROI around the motor in the image.
- 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.
- 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.
- 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.
- Delete any unwanted images by selecting the image in the browser and clicking Delete.
- Select File»Save Classifier File.
- Enter Tutorial.clf in File Name for the classifier file, and then click Save.