# 7 Network accuracy analysis
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
**Parent Topic:** https://docs.qualcomm.com/doc/80-PT790-993B/topic/dl_inference_tools_part.html
## 7.1 Accuracy tune
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
**Parent Topic:** [Network accuracy analysis](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
## 7.1.1 Accuracy evaluator
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
The accuracy evaluator is a framework to define and execute the end-to-end accuracy evaluation of a given model. The evaluation pipeline is configured in a YAML configuration file for a model and the tool loads this configuration file to execute the pipeline.
The pipeline consists of the stages shown in the following figure. The tool has options to run the complete pipeline or parts of the pipeline.
- Selecting a dataset.
- Running preprocessors on the dataset.
- Running inference on the processed data on one or more platforms.
- Postprocessing of inference raw outputs.
- Accuracy metrics evaluation.
Figure : Accuracy evaluator

**Parent Topic:** [Accuracy tune](https://docs.qualcomm.com/doc/80-PT790-993B/topic/Accuracy-Tune.html)
## 7.1.1.1 Jupyter notebook examples
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
The user can refer to the Jupyter notebooks located in the `/opt/qti-aic/tools/qaic-pytools/docs` folder to get started with the accuracy evaluator tool. The following table provides brief descriptions of each Jupyter notebook. The notebooks showcase usage of the evaluator tool under different scenarios.
Table : Notebook descriptions
| Notebook name | Description |
| --- | --- |
| Introduction\_to\_Accuracy\_Evaluator.ipynb | Shows minimal utility by comparing model outputs of a ResNet-50 model across the Cloud AI 100 device and ONNX runtime using a preprocessed dataset across different precisions and quantization schemes on the AI 100. |
| Using\_Evaluator\_with\_Built\_In\_Plugins.ipynb | Shows the steps to be followed to measure the mAP score of a Yolov5m model across the Cloud AI 100 device and ONNX runtime using built-in plug-ins over the original dataset. |
| Evaluator\_Advanced\_Usage.ipynb | Shows the various advanced use cases using the evaluator. |
| Writing\_Custom\_Plugins.ipynb | Shows the steps to be followed to create custom plug-ins. |
| Evaluator\_APIs\_Usage.ipynb | Shows the steps to evaluate a model using the evaluator APIs. |
**Parent Topic:** [Accuracy evaluator](https://docs.qualcomm.com/doc/80-PT790-993B/topic/introduction_accuracy_analysis.html)
## 7.1.1.2 Config file structure
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
The model configuration file defines the pipeline. Examples:
/opt/qti-aic/tools/qaic-pytools/samples/model_configs/resnet50_config.yaml
/opt/qti-aic/tools/qaic-pytools/samples/model_configs/yolov5m_nms_config.yaml
/opt/qti-aic/tools/qaic-pytools/samples/model_configs/yolov5m_no_nms_config.yamlCopy to clipboard
The high-level structure of the model configuration files is shown. The description of each of the sections follows.
Model
-info (optional)
-globals
-dataset
-processing
-preprocessing
-postprocessing
-inference-engine
-evaluator
Defaults: # Optional
…:….Copy to clipboard
**Parent Topic:** [Accuracy evaluator](https://docs.qualcomm.com/doc/80-PT790-993B/topic/introduction_accuracy_analysis.html)
## 7.1.1.2.1 Section info
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
This section is used to capture information about the model configuration in
desc (description field) and specify the batchsize to be
used in the tool for execution. Default batchsize is set to
1.
info:
desc: “Sample model config for Resnet50“
batchsize: 1
Copy to clipboard
**Parent Topic:** [Config file structure](https://docs.qualcomm.com/doc/80-PT790-993B/topic/accuracy_analysis_config-file-structure.html)
## 7.1.1.2.2 Section globals
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
The globals section can optionally be used to declare global variables that can be used across the complete configuration file.
For example, on the following declaration, the values of dim\_w and dim\_h can be used at any place in the configuration file with names as $dim\_w and $dim\_h.
globals:
dim_w: 640
dim_h: 1152Copy to clipboard
Global variables declared in the configuration file can be modified by the command line option (-set-global) of the evaluator tool without changing the configuration file (see [Inbuilt Dataset plugins](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html#inbuilt_dataset_plugins)).
**Parent Topic:** [Config file structure](https://docs.qualcomm.com/doc/80-PT790-993B/topic/accuracy_analysis_config-file-structure.html)
## 7.1.1.2.3 Section dataset
Source: [https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html](https://docs.qualcomm.com/doc/80-PT790-993B/topic/network-accuracy-analysis.html)
In this section, the user can define the dataset to be used for the accuracy evaluation. The user can either embed the entire dataset configuration in this section (see Syntax 1) or mention the name of dataset (see Syntax 2) and set up relevant information in datasets.yaml.
**Syntax 1**:
dataset:
name: COCO2014
path: '/prj/ml-datasets/COCO/2014/'
inputlist_file: inputlist.txt
annotation_file: annotations/instances_val2014.json
calibration:
type: index
file: calibration-index.txtCopy to clipboard
**Syntax 2**:
dataset:
name: COCO2014Copy to clipboard
Relevant information for the COCO2014 dataset using Syntax 2:.
/opt/qti-aic/tools/qaic-pytools/datasets.yamlCopy to clipboard
Example: The COCO 2014 dataset configuration in datasets.yaml. The name of the dataset should be a single word without any spaces.
COCO2014:
path: '/prj/ml-datasets/COCO/2014/'
inputlist_file: inputlist.txt
annotation_file: annotations/instances_val2014.json
calibration:
type: index
file: calibration-index.txtCopy to clipboard
The following table contains the details on the dataset fields in datasets.yaml.
Table : Dataset fields in datasets.yaml
| Path | Base directory of the dataset files |
| --- | --- |
| inputlist\_file | A text file containing all the input files relative to the “path” field – one input set per row.
Example:
val2014/COCO….jpg
val2014/COCOC…jpgCopy to clipboard
If the model takes multiple inputs, the inputs in each row are comma delimited. |
| annotation\_file | Path to the annotation/groundtruth file which is provided by the dataset or derived manually.
Note: The annotation file is passed to the metric plug-ins for accuracy evaluation. |
| calibration | Specifies the calibration file type to be used when using profile guided quantization (PGQ) in the compiler. Optional if not using PGQ.
Example: The calibration type could be ‘index’ or ‘raw’ or 'dataset.
| Calibration types | Description |
|---|---|
| index | file: calibration-index.txt (containing index) The file provided contains the indexes to be picked from the inputlist file for doing calibration. Example calibration index file: The index file can have indexes in multiple lines. |
| raw | file: calibration-raw.txt (containing paths to raw files) The user can provide a file with entries of the preprocessed raw files (one input set per row) to be used for calibration. |
| dataset | file: calibration-dataset.txt (containing paths to dataset files) In this case, the calibration images provided in the file are processed separately and passed to the inference stage. Note: The file paths provided may or may not be present in the inputlist file. |
| type | One of inbuilt comparator types (avg | abs | l1norm | l2norm | rme) or custom comparator. See Custom comparators on custom comparator configuration. |
| tol | Tolerance value – Depends on per comparator described below:
For all other inbuilt comparators – This defines the number of decimal places to round to before evaluating the comparator. |
| fetch_top | Out of all mismatched files, order by maximum % mismatch and write the fetch_top number of preprocessed input file paths in a file (<plat_name>_mm.txt) per platform. Default value: 1 |
| enabled | By default, enabled (True). |
| onnxrt | Runs on ONNX runtime platform. The version installed in the qaic-env is used ( default 1.8.0). This platform currently does not take any other parameter |
| tensorflow | Runs on TensorFlow (CPU). Supports TensorFlow frozen graphs. |
| caffe | Runs on Caffe framework (CPU). Only supported in qaic-docker environment. This platform currently does not take any other parameter. |
| aic | Runs on AIC cards installed in the system. The device to be used is selected from a pool (see aic-device-ids). |
| onnx_custom_op_lib | (Optional) Path to a custom-op library file that should be loaded to the ONNX runtime session. |
| precision | int8 | fp16 | fp32 / default |
| use_precompiled | Path to precompiled binaries. |
| reuse_pgq | Used to reuse the generated PGQ profile across the search space for compilation options for a given platform. Default is True. If set to False then the PGQ profile will be generated for all the generated platforms added after scanning over the search space for compilation options. |
| pgq_group | Can be any string. The same PGQ group can be provided to different AIC int8 platforms to indicate that the PGQ profile can be reused across these platforms. If reuse_pgq is set to False, then pgq_group is ignored. |
| params | Used only if use_precompiled is not provided or blank. Under params, the user can provide the compilation options. Details regarding these parameters can be referred from qaic-exec compiler documentation. Each line should contain one compilation parameter. Example below: params:
Users can also provide a search space for compilation options by separating values by a pipe operator. The example configuration below will result in four different platform configurations.
|
| is_ref | Optional parameter. Boolean value used to indicate the reference platform to be used by the comparator to compare with the model outputs. Generally, any non-aic platform would be chosen as reference platform unless explicitly specified. If no non-aic platform is present then first aic platform is chosen as reference platform. |
| use_gpu | Default False; flag used to determine if the user wants to run a non-aic platform on a GPU device. |
| gpu_ids | A list of GPU device IDs to use. Example: Note the tool automatically fetches available GPUs if use_gpu is True and gpu_ids are not provided by the user. |