<a id="easyclassify"></a>

# EasyClassify - Multi-label Image Classification

**EasyClassify** is the deep learning classification library of **eVision**. It classifies images into a predefined set of classes. Use this tool to identify a product in an image or to detect if the product is good or defective.

- API: [`EClassifier`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html)
- To create an **EasyClassify** project in **Deep Learning Studio**:
  1. Start **Deep Learning Studio**.
  2. Create a new project and select `EasyClassify` in the `New deep learning project` dialog.
     ![](assets/images/easydeeplearning/deeplearningstudio_1.webp)

<a id="easyclassify-properties"></a>

## Properties

![](assets/images/easydeeplearning/easyclassify_tool_properties.svg)

<a id="easyclassify-capacity"></a>

### Capacity (1)

* The `Capacity` of the neural network (default: `Normal`) represents the quantity of information that it is capable of learning.
  * We recommend you to first train a `Normal` network on your dataset.
  * If the learning is working:
    * Try to use the `Small` or the `Large` network to get the performance (inference speed and accuracy) that best matches your application.
  * If the learning does not work it means either that:
    * Your dataset image resolution is too small (below 128 × 128): try to use the `Extra Small` network that specifically targets such cases.
    * Your dataset is large and difficult: try to use the `Extra Large` network that specifically targets such cases.
* In the API:
  * Use the string parameter [`EClassifier::SetModelType`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad1e35d2cc951aa9c2768421d105f3098) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a605d4e09a40c66d010119660fd042055) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a2777d9455e984082db9c933c3b6d17cb) to select the model capacity.
  * Use [`EClassifier::SetModelType`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad1e35d2cc951aa9c2768421d105f3098) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a605d4e09a40c66d010119660fd042055) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a2777d9455e984082db9c933c3b6d17cb) to set the capacity of your tool.
  * Use [`EClassifier::GetAvailableModelTypes`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a23b9e2682a7706e024c2e781daab48ac) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a2a6dc2e70477bfb90ae0a9a330d821a0) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a2d170c55bc7d7ead857cdb35d8453d8e) to list the available models for training.

<a id="easyclassify-previously-trained-network"></a>

### Using a Previously Trained Network for a New Training (2)

* You can easily import a previously trained model and use it as the base of a new training.
* Use this feature when you want to improve a model after adding several new images to the dataset used for its training.
* In the API, use the method [`EClassifier::LoadAsPretrained`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#aa199e5147d0e1bb7f68635ef1f03a5b0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a478b6ada49cc14ade4494bb06fad8181) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a50ab846206bb1b65a83a5d65a891d262).

#### NOTE
The difference between re-using a trained network and continuing a training on the same tool is that all training variables and the decision-making layers are reset, allowing the network to learn again.

<a id="easyclassify-image-format"></a>

### Image Format (3)

* The `Width`, `Height` and `Image type` corresponds to the input image format of the neural network.
  * By default, a classifier uses the 224 × 224 format which was used during the pre-training of the network. The image size has the following constraint:
    * Minimum: 128 x 128
    * Recommended: 224 x 224
    * Maximum: 1024 x 1024
    * The performances may start to deteriorate if the height or/and the width are smaller than the recommended size.
  * Your images will be automatically reformatted (anisotropic rescaling and conversion between color and grayscale) to this image format unless [`EClassifier::SetEnableAutomaticImageReformat`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ab451220c17c4d345871f69e58a832715) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a03f2fb3c236b99e914408c339a4be1a6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a0358f26845b4977c615e569e400bc7d9) is disabled. In this case, the classifier throws an exception if the images do not have the correct image format.
  * In the API, you can also set manually the input image format with the methods  [`EClassifier::SetWidth`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a2ff8572d10b877a6bc430dd144ef4ee0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ae9f6a9c7decc565e642331dc7bac9019) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#abbe23da7fedead5ed94a6a8772a461e9),  [`EClassifier::SetHeight`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a69e316621bad9c99965fe8d471704346) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a36d22f1d9572aedbcce23dff214b002f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a195a7303742c50f7683781333227d8c6) and  [`EClassifier::SetChannels`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#acfd70ca1a72ba3575ae447d79c7499e8) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#aeb1cc6bb037136da0ebe478b894fef4c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a889be2c5cfe61cf776ae70f05fa3fbe3) (1 channel for grayscale images and 3 channels for color images).

#### NOTE
For the best processing speed, use the lowest resolution above the *recommended* resolution at which your *objects of interest* are still recognizable.

If your original images are larger than the maximum resolution, lower the resolution:

* If the *objects of interest* are still recognizable, explicitly set the input image format of the classifier to this lower resolution.
* If the *objects of interest* are not recognizable, divide your original images into sub-windows and use these sub-windows to train the classifier and make predictions. This presents the additional advantage of localizing the “object of interest” inside the original image.

![](assets/images/easydeeplearning/easyclassify_2.webp)

<a id="easyclassify-pretrained-models"></a>

### Pretrained Models (4)

* A pretrained model should give faster convergence time and better accuracy for all the datasets except for extremely large datasets (> 10 000 images).
* A pretrained model works by initializing the neural network with the weights learned on a large and complex dataset.
* This allows to transfer the knowledge of some universal features (such as edges, corners…) learned on this dataset to your dataset.
* If you do not use a pretrained model, the neural network is initialized randomly.
* In the API, use [`EClassifier::SetUsePretrainedModel`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad8b528b1e1793857e96e123846da258c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#abd5488e4777939c9979d375fc56bfeb7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a74c46c16d8592ed71adc9cd96bd5d5b1) to disable the user of pretrained models.

#### NOTE
You cannot use the histogram equalization with pretrained weights as it would lead to poor training results.

<a id="easyclassify-compute-heatmap-property"></a>

### Heatmap (5)

* If the option `Compute the heatmap` is checked, the tool computes the heatmap along with each result.
  * The heatmap is available with [`EClassificationResult::GetHeatmap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a21eeda0f73c49df3a90553209c5d5d26) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a7b4779983038dbad2036d732420bb059) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ac83735e9cc1274c9e09edde9f2a4607e).
  * Note that this option makes the computation of the results a bit slower but twice faster than computing the result and then computing the heatmap separately.
* In the API, use [`EClassifier::SetComputeHeatmapWithResult`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a76b68a1099b66414bdabd58fec5885d1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ab4c045ef8bcf9bfc581ee2c9a93cb657) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#af895daad40b128678bc5e6063662b4f7) to enable or disable this option.
* If this option is disabled, use the method [`EClassifier::GetHeatMap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad72f6f25a55b8a23aba31fd7da50b396) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a7030b07cca85561045d563d8a888298b) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a11e36015c742732fc0e57d1520ec1689) to get the heatmap for an image.

<a id="easyclassify-histogram-equalization-property"></a>

### Histogram Equalization (6)

* The classifier can apply an histogram equalization to every input image.
* Click on the `Enable histogram equalization` checkbox to activate it.
* In the API, use [`EClassifier::SetEnableHistogramEqualization`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a691bfa13f5f086dc3bec83a8bf38af5f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#aafb2e0fc86686840a070b43d0a330267) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a12db0ad12b4e5d9b4e80792c94a89cf8) to activate it.

#### NOTE
You cannot use the histogram equalization with pretrained weights as it would lead to poor training results.

<a id="easyclassify-ood-property"></a>

### Out-Of-Distribution Detection (7)

The classifier can learn to detect out-of-distribution images. This allows the detection of previously unseen elements, such as new defects, lighting or position changes or wrong products.

The `Out-Of-Distribution detection` assigns a score to each image between 0 and 1. A higher score is correlated with a higher distance from the learned image distribution.

* In **Deep Learning Studio**:
  * OOD is activated by default.
  * Deactivate it in the `Advanced parameters` menu.
* In the API:
  * Use [`EClassifier::SetComputeOODWithResult`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a1165aa2f03daf25291139558f68393d1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad73a3195cc98b76d885b5a439e15f69d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a0d1aec3694c86a63142bea9e2c0d04d0) to enable or disable OOD analysis (the OOD analysis is enabled by default).
  * Use [`EClassificationResult::IsOOD`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a88a010288dc7e61dce154fba80fb9090) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a3a30b8cff19fce0c578b2d45b0eb41e3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ac58299c6b87ee5234897e0d0bd9fcee5) to retrieve the OOD result.
  * Use [`EClassificationResult::GetOODScore`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aca3b96c07e4bac8fdaa5e199683976eb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a918fc3c87273e67696427dfe1f68a628) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ad2aa2770905cbf50c2a6ef7407b86d4d) to retrieve the OOD score.
  * Use [`EClassificationResult::GetOODThreshold`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a6f444969523e199910583801f3141af8) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a0ad67d26cafd7f495d77a87e86f5fbcd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a092f6a27bb6ae405a917ba55e91d269c) to retrieve the corresponding threshold.

#### NOTE
The OOD scores can only be calculated in classifiers trained with the OOD detection enabled.

An existing model can learn the OOD parameters with [`EClassifier.LearnOODParameters()`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a470c4403baff6e622979642a5520a0a5) (the inputs of this method must be the same as the inputs used to train the classifier).

<a id="easyclassify-training"></a>

## Training

To train your tool, see [Training a Deep Learning Tool](../easydeeplearning/training_a_deep_learning_tool.html.md).

<a id="easyclassify-validation"></a>

## Validating the Results

<a id="easyclassify-dlstudio-validation"></a>

### Deep Learning Studio

* The metrics are always computed without applying data augmentation on the images.
* In the tab `Tools`, the metrics `Best validation error` and `Best validation accuracy` are computed during the training using the label weights. The evolution of several metrics during the training is also available.
  ![](assets/images/easydeeplearning/easyclassify_3.webp)
* The results are available in the tab `Validation and Results`.
  ![](assets/images/easydeeplearning/easyclassify_3b.webp)
  * There are 3 metrics displayed:
    ![](assets/images/easydeeplearning/easyclassify_4.webp)
    * The `weighted error` and the `weighted accuracy` (normalized with respect to the label weights instead of being dependent of the number of images for each label).
    * The `dataset accuracy` (it does not use the label weights).

    #### NOTE
    If your dataset has a very different number of images for each of the labels, it is called  ***unbalanced***. In this case, the dataset accuracy is biased towards the labels containing the most images (the dataset accuracy mainly reflects the accuracy of these labels).
  * In the tab `Classification`, the confusion matrix shows the number of images according to their true labels and their label predicted by the classifier.
    * The diagonal elements of the matrix shown in green are the correctly classified images.
    * All the other elements of the matrix are badly classified images.
    * Select one or more elements of the matrix to show the corresponding images.
      ![](assets/images/easydeeplearning/easyclassify_5.webp)
  * The tab `OOD` displays:
    ![](assets/images/easydeeplearning/easyclassify_5c.webp)
    * The number of samples that are identified as out of distribution.
    * The corresponding OOD threshold.

      #### NOTE
      If the default threshold value is not satisfactory, you can manually input a threshold in `Adapting the OOD threshold` or use the mouse to drag the threshold on the score histogram.
    * Individual images identified as OOD are highlighted in red.
  * In the table, click on the cells and the headers to select OOD or non-OOD images and specific labels.
* Use the button `Export heatmaps` below the metrics widget to export the heatmap for each image of your dataset.
  * The heatmaps are saved in the PNG format under the name `ImageName_ToolName_heatmap_UniqueId.png`.
  * This feature requires a **Deep Learning** license.
* Use the button `Export results to CSV` below the metrics widget to export the results for each image of your dataset as rows of a CSV file.
  * Each record contains the image filename, the ground truth label, the predicted label, the prediction probability, the OOD detection result and the probabilities for all the labels recognized by the tool.

![image](assets/images/easydeeplearning/easyclassify_7.webp)

<a id="easyclassify-api-validation"></a>

### API

* After the completion of each iteration, **EasyClassify** automatically computes several performance metrics about the training and validation dataset:
  * Call the methods [`EClassifier::GetTrainingMetrics`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a370fd2e681a3bfb9f6c71d4994959a84) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a5214be0a2693bad9fd5535f4e470e43e) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#abc881b33eb3c50dfdfd91032fa455a55) and [`EClassifier::GetValidationMetrics`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#abd4a1c9228e7d589e2f5e58b1feae5a6) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#af4d31db62a794ec843a06890bbf43a2f) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ad22b0a1365c5f85c3a6e3315ea91947d) to read these metrics.
  * The iterations are indexed between 0 and [`EDeepLearningTool::GetNumTrainedIterations`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#a77620b0a5177802f4b701254543ae7ac) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#aca5443c22c0dfbcb9e5ad5d623d3687a) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#a48d2fcd2b92dd7949a9e98d78212d9c0)-1.
  * Call [`EDeepLearningTool::GetBestIteration`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#a6a24870f32bc106ed2e5a0b92ff85f36) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#adbdab8fa1214130de030fdf0be9f5e9c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EDeepLearningTool.html#a0f7711f3fb2d569f8185ebadf0a80fab) to retrieve the iteration that produced the best performance.
  * After the training, the classifier is back in the state corresponding to this best iteration.
* The metrics are represented by an [`EClassificationMetrics`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html) object that contains the following performance metrics:
  * The classification error ([`EClassificationMetrics::GetError`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a077daac9fef8137d83dc4c6520b213c0) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#ad1809749c5044e237d9b7bab63a8f2d4) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a67b96704327a2a08d8ba6ed4513a6f3f)), also called the cross-entropy loss: the quantity that is minimized during the training. It is computed from the probabilities computed by the classifier.
    * The error for a single image is the negative of the logarithm of the probability corresponding to the true label of the image. So, if this probability is low, the error for the image is high.
    * The error of the dataset is the average of the errors of each image in the dataset.
  * The classification accuracy ([`EClassificationMetrics::GetAccuracy`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a264de27a5af8d70b40072f64234602cb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#ade1a1cb3920830339ead381d5796ec48) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#af37428a08902bb51d039c018ae210a22)): the number of images correctly classified divided by the total number of images in the dataset.
  * The confusion matrix ([`EClassificationMetrics::GetConfusion`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a77372dd08b6d2454401395d579de5871) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a75cb981e062460be9a76d61b5d107ab7) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationMetrics.html#a507594fab2045e6189976435fc35d36c)): the number of images labeled as `groundtruthLabel` that are classified as `predictedLabel`.

#### NOTE
Call [`EClassifier::Evaluate`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a636d344a524cc9640f79b4cc7c8f781c) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ab628efd9fb17a3458d618e6955e2210c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#aaaf2c11b0fb6dc4ebc0bf87af569fc3b) to evaluate a dataset independently of the training.

<a id="easyclassify-inference"></a>

## Classifying New Images

#### SEE ALSO
Some **eVision Studio** samples illustrate aspects of **EasyClassify**:

* `Deep Learning Classification`: classification and heatmap on the `MiniWaffle` dataset.
* `Out of distribution (OOD)`: Out of distribution detection on the `Stone Tiles` dataset.

See [Additional Resources](../deep_learning_studio.html.md#easydeeplearning-dlstudio-additional-resources) for details about the datasets and how to get them.

<a id="easyclassify-dlstudio-inference"></a>

### Deep Learning Studio

* Include the new images in the test set
  1. Add new images to the dataset from the `Dataset and annotations` tab.
  2. In the `Validation and results` tab, refresh the results
     ![image](assets/images/easydeeplearning/easyclassify_6.webp)
* Use the `Inference tests` tab to classify the new images and display the detailed results for these images.
  * You can also export the results to CSV or export the heatmap from this tab.
* In the image viewer, you can enable or disable the heatmap visualization and configure how the heatmap is displayed (color map and transparency).
  ![](assets/images/easydeeplearning/easyclassify_8.webp)

<a id="easyclassify-api-inference"></a>

### API

* Once the classifier is trained, call [`EClassifier::Classify`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a114b7a7ca07cc870bec47858a84d26a5) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ae598eb6acaa59a266a9b1ca2d027c194) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ac3b907efadeae37864a4b603d633f4f7) to classify an **eVision** image.
  This method returns a [`EClassificationResult`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html) object:
  * [`EClassificationResult::GetBestLabel`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a4d242b0c316b8e1e95dd366eb34fae2b) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a16e3fb0f5bc1e4dd2a2e6c3e9f4328d6) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a196c8bcd94e584d0a02691458174b063) returns the most probable label for the image.
  * [`EClassificationResult::GetBestProbability`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a27e0e9d4a576c00f45909e5f91d56592) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aa40cfae03e116c6e4810f9296d6c1f81) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aacdc3742808ba5d1ae0197bda8a98039) returns the probability associated with the most probable label.
  * [`EClassificationResult::GetProbability`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a833a0cd3397af4ba766c9dea6b17bf5f) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ae7580702dd81cb93f40cf64b64396f1a) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ad41a7f90502203cec47cc3d725276735) returns the probability associated with the given label.
  * [`EClassificationResult::GetRanking`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a2e6af57d21064428d48065750c9f5325) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ae6797d8e27eafd512e489419c28480e3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a3326c102f8db71eecd2335cad8c535fc) returns the ranking of the given label. The ranking goes from 1 (most probable) to [`EClassificationResult::GetNumLabels()`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aed6c55bfde4550f15a9e8606e66db380) (least probable).
  * [`EClassificationResult::GetHeatmap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a21eeda0f73c49df3a90553209c5d5d26) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a7b4779983038dbad2036d732420bb059) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ac83735e9cc1274c9e09edde9f2a4607e) and [`EClassificationResult::GetColorizedHeatmap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a6c7a2ae6e90498448c0d026d1e6cc879) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a226d0ea0aea8571ded710582775cea24) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aab169f886f176d6f8df63b1e0af6f521) return a heatmap highlighting the pixels that have contributed the most to get the most probable label.
    * The heatmap is only available when the classifier property [`EClassifier::SetComputeHeatmapWithResult`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#a76b68a1099b66414bdabd58fec5885d1) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#ab4c045ef8bcf9bfc581ee2c9a93cb657) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html#af895daad40b128678bc5e6063662b4f7) is set to `True`.
    * Use [`EClassificationResult::HasHeatmap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a7dde2d0e0d29cc533a79999ffd4593ed) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a25dddafbc7942cfb96df28e534a1590c) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ade372ce52a741329525395605b2c40db) to check if the result contains a heatmap.
  * [`EClassificationResult::HasOODScore`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aa632c618b11b66c152330208f52db4aa) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a121bac2b250829ca041d0f09f173ec7d) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a4d76fa01bb5865b11ee9787b66b4fa39) returns whether the OOD score is available for the given result.
    * If it is available, [`EClassificationResult::IsOOD`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a88a010288dc7e61dce154fba80fb9090) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a3a30b8cff19fce0c578b2d45b0eb41e3) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ac58299c6b87ee5234897e0d0bd9fcee5) returns a boolean that indicates whether the result is out of distribution.
    * Use [`EClassificationResult::GetOODScore`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#aca3b96c07e4bac8fdaa5e199683976eb) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a918fc3c87273e67696427dfe1f68a628) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ad2aa2770905cbf50c2a6ef7407b86d4d) and [`EClassificationResult::GetOODThreshold`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a6f444969523e199910583801f3141af8) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a0ad67d26cafd7f495d77a87e86f5fbcd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a092f6a27bb6ae405a917ba55e91d269c) to retrieve the specific score and threshold.
    * Use [`EClassificationResult::SetOODThreshold`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a91a990e94408d8f388512b2067d3fb1e) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a0ad67d26cafd7f495d77a87e86f5fbcd) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a092f6a27bb6ae405a917ba55e91d269c) to manually change the threshold.
* You can also do *batch classification* or directly classify a vector of **eVision** images:
  * Images are processed together in groups determined by the batch size.
  * On a GPU, it is usually much faster to classify a group of images than a single image.
  * On a CPU, implement a multithread approach to accelerate the classification. In that case, each thread must have its own instance of [`EClassifier`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassifier.html) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassifier.html) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassifier.html) (see [code snippets](../../../resources/code_snippets/deep_learning_inspection/easyclassify/index.html.md)).

  #### NOTE
  The batch classification has a tradeoff between the throughput (the number of images classified per second) and the latency (the time needed to obtain the result of an image): on a GPU, the higher the batch size, the higher the throughput and the latency. So, use batch classification to improve the classification speed at the cost of a longer time before obtaining the classification result of an image.
* Use [`EClassificationResult::GetHeatmap`](../../../doxygen_cpp/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a21eeda0f73c49df3a90553209c5d5d26) [<sub>.NET</sub>](../../../doxygen_cs/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#a7b4779983038dbad2036d732420bb059) [<sub>Python</sub>](../../../doxygen_python/classeVision_1_1EasyDeepLearning_1_1EClassificationResult.html#ac83735e9cc1274c9e09edde9f2a4607e) to obtain a heatmap highlighting the pixels that contribute the most to a label.
  * In some cases, this heatmap can provide a rough localization of the object corresponding to the label.
  * The heatmap is colored, and the important parts are displayed in red.

  #### NOTE
  Since large memory allocations take a lot of time, a classification does not release its memory and the next classifications can reuse it as long as the width, height, batch size and computation device remain the same. As such, the first classification is always slower due to the memory allocations.
