# Process Neural Network (Inferencing)

At runtime, each sample from the runtime image is processed individually, using the tool's trained network, and an individual network response is obtained for each sample. The response from the network is expressed as a probability map, where each pixel in the sampled region of the input image is assigned a probability. The meaning of the probability map depends on which tool is being used. For the Blue Locate tool, the response is the probability that the center of a labeled feature lies within that pixel, and if that probability exceeds a threshold value that you specify, then the tool also provides the feature identity and the probability that the identification is correct.

These whole-image probability maps are assembled from the interpolated network responses to individual samples. The final results returned to the user (feature poses and identities, and defect regions) are based on a results formation process that the user controls by specifying thresholds for match quality.

In the above context, it is important to understand that the probability returned by a tool may not reflect well with our notion of how likely a certain judgment is. This is mostly due to the fact that the tools have a "limited view of the world" in that they do not return probabilities with respect to our wide and rich visual experience, but rather with respect to their very limited visual world of a couple of classes.

The processing (inferencing) of a trained tool is automatically executed when the training is finished without issues. If you want to manually re-process the trained tool, click button.

## Feature Sampling for Processing

Each input image is exhaustively sampled at runtime, and the individual samples are then processed by the trained network. The same feature size used for training is also used at runtime (ensuring that the trained network is processing inputs that are consistent with the inputs used for training).

Unlike training, where the sampling density is determined automatically, you can control the runtime sampling density for all the Deep Learning tools. The sampling density determines the degree of overlap between adjacent samples. A sampling density rate of 1 means that the sampling location is incremented by the feature size between samples. The default sampling density rate for most tools is 3, which means that the sampling location is incremented by one third of the feature size.

Sampling Density = 1 (4 samples) | Sampling Density = 3 (4 samples)
--- | ---

The Blue Locate tool provides additional user controls over sampling at run time. The Blue Locate tool performs additional interpolated sampling at locations where it detects features. It uses these additional samples to refine the feature pose. You can control the number of additional sampling passes using the Precision parameter, which specifies the degree of pose improvement at which resampling is stopped.

## Configure Processing Parameters

The Processing parameters control the way that images are processed by the tool. This is often called ‘inference’ in deep learning. Processing with the same models will always give you the same results. Changing these parameters does not require the tool to be retrained; the effect can be seen right away by reprocessing the database. To re-process the tool, click button.

Parameter | Description
--- | ---
Sampling Density | Specifies the density of sampling points with respect to the tool's Feature Size (FS) setting. The sampling density determines the degree of overlap between adjacent samples. A sampling rate of 1 means that the sampling location is incremented by the feature size between samples. The default sampling rate for most tools is 3, which means that the sampling location is incremented by one third of the feature size. Tip: One key aspect of the Sampling Density parameter is the relationship between the tool's processing time and accuracy. A tool's processing time depends approximately quadratically to the Sampling Density (Sd) value. For example, a Sampling Density setting of 1 is approximately nine times faster than a setting of 3 (n2). While higher Sampling Density settings are more accurate, it significantly impacts the processing time of the tool.
Threshold | The Threshold determines how closely the found feature must be to the desired feature in order for it to be considered detected. The found feature must exceed the setting.
Angle Range | Provides for degrees of freedom (DOF) of features than can be reported by the tool. Specifies the specific range (the minimum and the maximum values) of rotation that can be accommodated by the tool. This parameter is available only when the Oriented parameter in Features parameters is enabled.
Size Range | Provides for degrees of freedom (DOF) of features than can be reported by the tool. Specifies the specific range (the minimum and the maximum values) of scale that can be accommodated by the tool. This parameter is available only when the Scaled parameter in Features parameters is enabled.
Aspect-Ratio Range | Provides for degrees of freedom (DOF) of features than can be reported by the tool. Specifies the specific range (the minimum and the maximum values) of aspect-ratio that can be accommodated by the tool. This parameter is available only when the Scaled parameter in Features parameters is enabled and set to Non-Uniform.
Precision | The Precision parameter refines the position of a feature iteratively. With each iteration, a new feature position is computed. The Precision parameter controls when this refinement is terminated. Feature position refinement is repeated until the difference between the current position and the new, refined position is less than the specified precision, multiplied by the Feature Size. For example, if you have a Feature Size of 40, and a Precision setting of 5%, the tool will stop searching for the position of the feature when the next jump would be less than 2 pixels (0.05 * 40 = 2 pixels).
| If Precision is equal to 400%, the Blue Locate tool will stop at D0. 200% = D1 100% = Matches with precision
Stop criteria: |
Feature Filter | Specifies a filter based on feature id, x, y, size and orientation, which is used as criteria for found features. By specifying a filter for features, features that do not match the filter will be removed from the results. If the parameter is left blank, all features will be returned. Since this filtering is done after the tool has processed the images, the features are not removed, simply hidden from the results. Features that are not present due to the filter will reappear, without reprocessing the image, by removing the filter criteria. Note: The syntax for filters is the same as that used for Display Filters. For more information about constructing the syntax for a filter, see the Custom Display Filters. For example, if the Feature Filter parameter was set to the following:
Feature Filter | Description
--- | ---
x in [0,view.width] and y in [0,view.height] | With this filter, only features whose center is within the ROI will be returned.
(id = '0' and x < 200) or (x='1' and x > 200) | With this filter, assuming a View that has a width of 400, features that have an ID of 0 and are on the left, and features that have an ID of 1 and are on the right, will be returned.

Note: The Feature Filter parameter is only available when Expert Mode is enabled.

### Processing Parameter Details: When "Scaled" or "Oriented" (Features Parameter) are Enabled

By default, the Blue Locate Tool and Blue Read Tool allow you to specify the absolute range of feature (or characters for the Blue Read tool) sizes, in pixels, to match. Features with sizes in the search range will be matched, and those outside the range will not be matched. If Scaled - Non-uniform in Features parameters is enabled, then the "size" of the feature is defined as the geometric mean of the X- and Y- dimension of the feature.

When considering the runtime scale range for non-uniform scale, the scale of a particular found feature is equal to the geometric mean of the X- and Y-sizes of the found feature, divided by the geometric mean of the X- and Y-sizes of the tool’s Feature Size.

- When the Scaled parameter is enabled, set to Uniform, the Scale Perturbation parameter will be removed, and a Size Range Processing parameter will be added so you can modify the scale during runtime.
- When the Scaled parameter is enabled and set to Non-uniform, the Scale and Aspect-Ratio Perturbation parameters will be removed, and Size Range and Aspect-Ratio Range Processing parameters will be added so you can modify them during runtime.

- When the Oriented parameter is enabled, the Rotation Perturbation parameter will be removed, and an Angle Range Processing parameter will be added, so you can modify the orientation range during runtime.

Note: For details of Scaled parameter, see Scaled
Note: For details of Oriented parameter, see Oriented

### Processing Parameter Details: Feature Filter for "Scaled" (Features Parameter) Features

If you have configured your Blue Locate tool to find both large and small features via the Scaled parameter in Features parameters, the tool may return matches at scale values where you do not intend to find features. In this event, it can be helpful to use the Feature Filter to remove the mismatched features.

For example, if you have a tool that has been trained to find large capacitors and small capacitors, during runtime and the Size Range parameter has been set with a range large enough to accommodate both the large and small capacitors, intermediate-sized matches are possible.

In this event, if you use the Feature Filter, you can define a mechanism to suppress these types of matches (for example "size > X or size < Y").

Note: For details of Scaled parameter, see Scaled

### Model Processing

For Blue Locate and Blue Read tools with defined models, the features found during neural network processing are searched for the feature collections that provide the best fit for the defined models.