# 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 Red Analyze tool in High Detail Mode, the response is the probability for each pixel in the sampling region, that the pixel is within an image defect.

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 defect probability.

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.

## 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.

Parameters | Description
--- | ---
Threshold | There are two settings, T1 and T2 (expressed as [T1,T2]. They determine the threshold which determines whether or not regions are detected and marked as good or bad. Values below T1 will be classified as good, and values above T2 will be classified as bad. The T1 and T2 values can also be set interactively using the Scores graphic in the Database Overview.
Auto | When you enable Auto (Auto-Threshold), it calculates Threshold values T1 and T2 that maximize the F1 score of confusion matrix on Database Overview by following each criterion in the dropdown menu. The 4 criteria are the same as the ones in Count dropdown menu on Database Overview. See Score Count Filter for more information.
Region Filter | Specifies a filter for the tool to be used as criteria for found regions. By specifying a filter, regions that do not match the filter will be removed from the results. If the parameter is left blank, all regions will be returned. 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. The available region properties are: score area perimeter compactness x y
Downsampling Size | The magnitude of downsampling. The result of the processing, which is a heatmap that consists of defect probabilities for the input view, is downsampled with a kernel whose size is of this level. For example, if the size of the result is 128x128 with Downsampling Size of 16, Red Analyze High Detail Mode downsamples this with a 16x16 kernel. In this case, the downsampled result becomes an 8x8 patch that contains pixels of the highest defect probabilities in the original a 128x128 output. Then Red Analyze High Detail Mode reconstructs this 8x8 patch into 128x128 heatmap which is the final result. Generally the higher Downsampling Size gives out the faster processing time with the increased recall but some loss in the precision. The available value for Downsampling Size is from 1 to the size of view (the width or the height of view). Changing this value requires more time for re-processing compared to changing other processing parameters, accompanied by a slight change of the processing result due to randomness. Note: Depending on your images, increasing Downsampling Size might result in a decrease in Process Speed. This is natural since increasing the size of the downsampling kernel decreases the amount of blob calculation in Processing but adds more image compressions at the same time.
Whole Image Processing | When you enable Whole Image Processing, the tool will process each image as a whole. This option is enabled by default, and disable this option when there is not enough available GPU memory or the size of images does not fit on the available GPU memory. If this option is disabled, the tool will process each image by a different method. If you change the size of images to be processed, enabling this option could temporarily slow down the processing speed. The processing speed will recover once the tool's network is adapted to the current image size.