# Train Unsupervised Type Red Analyze

You train the tool with "Good" images to locate anomalies within an image. The training image set A collection of images of your specific application. A training image set represents images of a specific part or process acquired in a consistent way using the lighting, optical, and mechanical characteristics of your runtime system. The training image set includes images that represent the range of image appearances that you expect to see in normal operation. for the Unsupervised type tool is simply a collection of defect-free images.

The Unsupervised type tool samples pixels with a feature A feature is a visually distinguishable area in an image. Features typically represent something of interest for the application (a defect, an object, a particular component of an object). sampler that is tied to a sampling region. You define the sampling region with the sampling parameters in the Tool Parameters sidebar. If a sampling region does not include any defect pixels, then the network should produce no response.

## Prerequisites

- You have created or imported a workspace into VisionPro Deep Learning application.

- You have collected images and loaded them into the application.

## Procedure

1. Add a Red Analyze tool and set the Type parameter to Unsupervised.

2. Define ROI The Region of Interest (ROI) defines the area of operation for the tool. The ROI preserves the positions, angles, stretch and skew of the original image. (Region of Interest) to construct Views.
   1. If a pose from a Blue Locate tool is being used to transform the orientation of the View being used as an input to the Red Analyze tool, process the images (press the Scissors icon) before opening the Red Analyze tool.

   2. If necessary, adjust the Region of Interest (ROI). Within the Display Area, right-click and select Edit ROI from the menu.

   3. After adjusting the ROI, press the Apply button and the adjusted ROI will be applied to all of the images.
   4. Press the Close button on the toolbar to continue.
3. If there is extraneous information in the image, add appropriate masks to exclude those areas of the image. Within the Display Area, right-click and select Edit Mask from the menu.

   1. From the Mask toolbar, select and edit the appropriate masks.

   2. After adding the necessary mask(s), press the Apply button and the mask will be applied to the current image.

      If you click Apply All and click Yes button on the ensuing Apply Mask dialog after adding the necessary masks, the same mask will be applied on all the images. If you click No on the dialog, the mask will not be applied and you go back to the Edit Mask window.

   3. Press the Close button on the toolbar to continue.
4. Go through all of the images and label the images as Good or Bad. Make sure that all of the images have been labeled.
5. Split the entire images into the training Training is the process that your tool, which is a neural network, is learning about the features (pixels) based on the labels you made. For example, a tool will learn the defect/normal pixels in each image based on the defect/normal labels you drew. The goal of the tool Training is learning enough to give the correct inspection results of whether an unseen image is defective or not. The key to training is to ensure that you include all possible variations within your training set, and that your images are accurately labeled. Training times vary by the application, tool setup and the GPU in the PC being used to train the network. images and the test images. Utilize image sets to properly divide them into the training and test group. Add images to the training set.
   1. Select the images in the View Browser, and on the right-click pop-up menu click Add views to training set. To select multiple images in the View Browser, use the Shift + Left Mouse Button.
   2. Or, use to show the desired images for the training only and add them to the training set by clicking Actions for ... views → Add views to training set.
6. Prior to training, you need to set parameters in Tool Parameters. You can configure Training, Sampling, and Perturbation parameters or just use the default values of these.
   1. Ensure that the Feature Size parameter has been set. The Feature Size parameter gives the network a clue to the size of the defects that you are interested in detecting. So, if the Feature Size parameter setting is larger than the defects in your application, there is a good chance the tool will not identify the defects in your image.
   2. You can set the Feature Size by either manually adjusting the parameter value, or graphically by re-sizing the interactive Feature Size graphic.
   3. If you want more granular control over training or processing, turn on Expert Mode on Help menu to initialize additional parameters in Tool Parameters.
7. Train the tool by pressing the Brain icon.
   1. If you stop training in the middle of it by pressing the Stop icon, you can stop training but you will lose the current tool so far trained.

8. After training, review the results. Open Database Overview panel and review the Scores/ROC The Receiver Operating Characteristic (ROC) is a graphical tool that allows you to visualize and analyze the tradeoff between precision and recall exhibited by a particular set of training parameters when applied to a particular training image set. graph, the Confusion Matrix, and its F1 Score with switching over between categories in Count drop-down list.

9. After reviewing the results, go through all of the images and see how the tool correctly or incorrectly marked the defects in the image.
   1. If the tool has correctly marked the features, right-click the image and select Accept View.
   2. If the tool has incorrectly marked the defects, or failed to identify a present defect:
      1. Right-click the image and select Accept View.
      2. Right-click the image again and select Clear Markings and Labels.
      3. Manually label the defective image.
   3. If you want to tune the result by affecting the processing, adjust the processing parameters and re-process by clicking Magnifier icon. For example, to change the decision boundary, adjust the Threshold parameter.
   4. If you encountered the scenario in (a.), you are ready to use the tool. If you encountered the scenario in (b.), you will need to retrain the tool.