# Manual Conversion with SNPE (RVC4)

RVC4 conversion is based on the Qualcomm Neural Processing SDK ... SNPE tools. We provide a docker image with all the necessary
tools installed. Install the ModelConverter and run:

```bash
modelconverter shell rvc4
```

## Overview

This is equivalent to starting a new Docker container from the `luxonis/modelconverter-rvc4:latest` image and running it as an
interactive terminal session (`-it`) with the `--rm` flag to ensure the container is automatically removed once the session is
exited:

```bash
docker run --rm -it \
    -v $(pwd)/shared_with_container:/app/shared_with_container/ \
    luxonis/modelconverter-rvc4:latest
```

In the following section, we explain the conversion process step-by-step.

> **Note**
> Before choosing a specific SNPE build for RVC4, check the [SNPE compatibility table in Conversion Troubleshooting](https://docs.luxonis.com/software-v3/ai-inference/conversion/troubleshooting.md) to make sure it matches the DepthAI and Luxonis OS versions you plan to deploy on.

## Conversion to DLC

First, convert the model to the deep learning container (DLC) format. The following source model formats are supported:

 * ONNX
 * TensorFlow Lite

If converting from ONNX, run:

```bash
snpe-onnx-to-dlc --input_network <path to the .onnx model>
```

If converting from TFLite, run:

```bash
snpe-tflite-to-dlc --input_network <path to the .tflite model>
```

Note that no prior model simplification is required as SNPE handles that automatically.

> **Note**
> Consult the `snpe-onnx-to-dlc --help` or `snpe-tflite-to-dlc --help` for the full list of conversion options or visit the official [documentation](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-2/tools.html#snpe-onnx-to-dlc).

## Quantization (optional)

Second, the converted model is quantized to UINT8 precision. This step is optional and can be skipped if no quantization is
desired.

```bash
snpe-dlc-quant --input_dlc <path to the .dlc model>
```

> **Note**
> Consult the `snpe-dlc-quant --help` for the full list of quantization options or visit the official [documentation](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-2/tools.html#snpe-dlc-quant).

## Graph preparation

Third, the model is prepared to run on DSP/HTP accelerators.

```bash
snpe-dlc-graph-prepare --input_dlc <path to the (un-)quantized .dlc model> --htp_socs sm8550
```

> **Note**
> Consult the `snpe-dlc-graph-prepare --help` for the full list of graph preparation options or visit the official [documentation](https://docs.qualcomm.com/bundle/publicresource/topics/80-63442-2/tools.html#snpe-dlc-graph-prepare).
