> ## Documentation Index
> Fetch the complete documentation index at: https://dragonwingdocs-staging.qualcomm.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Integrating a custom AI model

> Choose the right Qualcomm SDK path when bringing a custom AI model into an application, using QIM SDK or the Qualcomm AI Runtime SDK.

This page helps you choose the correct SDK path for integrating a custom AI model into an application. **Start with the Qualcomm IM SDK (QIM SDK)** when your model fits a supported multimedia use case and can run through the standard preprocessing, inference, and post-processing pipeline. **Use the Qualcomm AI Runtime SDK (QAIRT) only when** you need lower-level runtime control, custom tensor handling, or an application workflow that is outside the QIM SDK path.

<Info>
  **Step 2a of the [application development workflow](../topic/imsdk-app-development#application-development-workflow).** Use this page as the decision point before implementation. It tells you whether you can continue directly with QIM SDK, whether you first need to add custom post-processing in step 3a, or whether the model should move to the QAIRT path.
</Info>

## Decision at a glance

Use the following decision flow to determine the most appropriate integration path for your model and application. Follow each decision point in sequence, starting with model readiness and ending with the recommended implementation approach.

<Note>
  **How to use this flowchart:** Answer each question (**Q1–Q3**) in order. If your use case is supported by QIM SDK, check whether an existing `qtimlpostprocess` module supports your model output. If it does, proceed to **step 4**, [Build the application](../topic/imsdk-build-application). Otherwise, complete **step 3a** to [add a custom post-processing module](../topic/add-postprocessing-support-custom-model), then continue to **step 4**. Use QAIRT only when your requirements cannot be met by the QIM SDK workflow. The [table below](#choose-the-right-integration-path) explains each decision in more detail.
</Note>

```mermaid theme={null}
%%{init: {"themeVariables": {"fontSize": "11px"}, "flowchart": {"htmlLabels": true, "nodeSpacing": 12, "rankSpacing": 22, "curve": "basis", "padding": 3}}}%%
flowchart TD
    classDef decision fill:#FFFFFF,stroke:#3253DC,stroke-width:1px,color:#1B1B1B;
    classDef sdk fill:#31017D,stroke:#31017D,color:#fff;
    classDef alt fill:#3253DC,stroke:#3253DC,color:#fff;

    Q1{"Q1 · Supported<br/>by QIM SDK?"}:::decision
    Q1 -->|"No"| RT["AI Runtime SDK /<br/>custom runtime"]:::alt
    Q1 -->|"Yes"| Q2{"Q2 · Model on<br/>AI Hub?"}:::decision
    Q2 -->|"Yes"| Ref["Adapt AI Hub<br/>reference pipeline"]:::sdk
    Q2 -->|"No"| BYOM["Bring your<br/>own model"]:::sdk
    Ref --> Q3{"Q3 · Post-processing<br/>module supported?"}:::decision
    BYOM --> Q3
    Q3 -->|"Yes"| Mod["Use existing<br/>qtimlpostprocess module"]:::sdk
    Q3 -->|"No · step 3a"| Custom["Add custom<br/>qtimlpostprocess module"]:::sdk
    Mod --> Build["Step 4 ·<br/>Build the application"]:::sdk
    Custom --> Build
```

## Choose the right integration path

Choose one of the following integration paths. **We recommend starting with the QIM SDK path**, as it supports most multimedia AI use cases and enables rapid development using existing components and reference pipelines. Choose the Qualcomm AI Runtime SDK (QAIRT) path **only if** your model or application requirements are not supported by QIM SDK and require custom implementation or lower-level runtime control.

| Option | QIM SDK (Recommended) | Qualcomm AI Runtime SDK |
| - | - | - |
| **When to use** | Your use case is supported by QIM SDK, and a compatible model is available from AI Hub or can be adapted to the QIM SDK pipeline. | Your use case requires functionality not currently supported by QIM SDK, custom tensor processing, or direct control over model execution. |
| **Development approach** | Build on the QIM SDK multimedia pipeline using prebuilt inference and post-processing components. | Develop a custom AI application using Qualcomm AI Runtime SDK APIs. |
| **Integration effort** | Low to moderate. Reuse existing pipelines and configure model-specific parameters. | High. Requires custom application development, integration, and validation. |
| **Next steps** | Continue to Step 3a if custom post-processing is required, then proceed to Step 4. | Follow the [Qualcomm AI Runtime SDK documentation](../topic/develop-your-own-application-qairt-cpp) to build and deploy a custom AI application. |

### QIM SDK (Recommended)

QIM SDK is the recommended integration path for most multimedia AI applications. Use this path when your use case is supported by QIM SDK and your model can be integrated into the standard preprocessing, inference, and post-processing pipeline.

Follow the decision points below to determine whether additional customization is required.

| Decision point | Yes | No |
| - | - | - |
| Is the target use case supported by QIM SDK? | Continue with the QIM SDK workflow and select the appropriate pipeline components. | Use Qualcomm AI Runtime SDK (QAIRT) to develop a custom AI application. |
| Is a compatible model available on Qualcomm AI Hub? | Use the AI Hub model and adapt the reference pipeline to your application. | Integrate your own model and verify its format, tensor specifications, and runtime compatibility. |
| Is the model output supported by an existing post-processing module? | Use the appropriate post-processing module and proceed to **step 4**, [Build the application](../topic/imsdk-build-application). | Complete **step 3a**, [Add a custom post-processing module](../topic/add-postprocessing-support-custom-model), then proceed to **step 4**. |

To determine whether an existing post-processing module supports your model output, run:

```shell theme={null}
gst-inspect-1.0 qtimlpostprocess
```

Compare the supported output tensor formats with your model's output tensors. **If a compatible module is available, you can use it directly. Otherwise, you must implement a custom post-processing module before building the application** — this post-processing check is the decision that determines whether your model works out of the box.

### Qualcomm AI Runtime SDK

<Warning>
  **Use only when QIM SDK does not fit.** Choose [Qualcomm AI Runtime SDK](../topic/develop-your-own-application-qairt-cpp) when the use case is not supported by QIM SDK, the application requires direct runtime-level control, or the model needs custom tensor handling outside the standard QIM SDK pipeline. This path usually requires more design, integration, and validation effort.
</Warning>

Use this table to map common integration scenarios to the recommended SDK path and expected effort.

| Scenario | Recommended SDK path | Reason | Expected integration effort |
| - | - | - | - |
| Supported use case with a Qualcomm AI Hub model | QIM SDK | Fastest path because preprocessing, inference, and post-processing are already aligned with the SDK workflow. | Low. Start from a reference pipeline and update model-specific parameters. |
| Supported use case with a custom but compatible model | QIM SDK with model adaptation | The use case fits QIM SDK, but model inputs, outputs, labels, or thresholds may need update. | Medium. Validate tensor shapes and update preprocessing or post-processing configuration. |
| Supported use case with unsupported output format | QIM SDK with custom post-processing | The pipeline can still use QIM SDK, but custom logic is required to convert raw tensors into metadata. | Medium to high. Implement and validate the custom post-processing module. |
| Unsupported use case or highly custom runtime flow | Qualcomm AI Runtime SDK | Use this path when the application needs direct runtime control, custom tensor handling, or a workflow outside QIM SDK supported patterns. | High. Plan for additional integration, validation, and application-level pipeline work. |

## Pre-integration checklist

Before integrating a model, gather the key information that influences the integration path and pipeline configuration. These details help determine whether the model can use existing QIM SDK components, requires custom post-processing, or is better suited for a custom implementation using Qualcomm AI Runtime SDK (QAIRT).

| Item | Why it matters | Used in |
| - | - | - |
| Model format | Determines whether the model is compatible with the supported inference framework and runtime. | Inference configuration |
| Input tensor shape | Must align with the tensor format produced by preprocessing. | Preprocessing configuration |
| Preprocessing requirements | Input format, resizing, normalization, and color conversion can affect model accuracy. | Preprocessing configuration |
| **Output tensor structure** | **Determines whether an existing post-processing module can process the model output — the key factor in whether you need a custom module.** | Post-processing configuration |
| Runtime target | Influences the runtime and hardware acceleration configuration used for inference. | Inference configuration |
| Post-processing requirements | Defines how model outputs are converted into application-ready metadata such as classifications, detections, masks, or keypoints. | Post-processing and application pipeline |

<Note>
  Before proceeding, make sure you know your model's input and output specifications, preprocessing requirements, target runtime, and expected output format. This information is required to select the correct integration path and pipeline components.
</Note>

## Next steps

Select the next step based on the result of the post-processing check. If an existing module supports the model output, continue to build. If no module supports the output, add a custom post-processing module first. If the use case is outside QIM SDK, use the QAIRT path.

<CardGroup cols={3}>
  <Card title="Post-processing supported — build the application" icon="hammer" href="../topic/imsdk-build-application">
    **Step 4** — an existing post-processing module supports your model. Build the application with the correct module options.
  </Card>

  <Card title="Not supported — add post-processing" icon="sliders" href="../topic/add-postprocessing-support-custom-model">
    **Step 3a** — no post-processing module accepts your output. Write and deploy a custom module, then continue to step 4.
  </Card>

  <Card title="Outside QIM SDK — use QAIRT" icon="code" href="../topic/develop-your-own-application-qairt-cpp">
    **Advanced** — the use case is unsupported or needs runtime-level control. Use the Qualcomm AI Runtime SDK instead.
  </Card>
</CardGroup>

## Related information

* [Qualcomm AI Hub](../topic/ai-hub) — browse and export pre-optimized models.
* [Develop an AI application using QAIRT C++ APIs](../topic/develop-your-own-application-qairt-cpp) — the advanced runtime-level path.
* [Run a Sample Application with a custom-trained model](../topic/customize-reference-app) — swap a model into an existing sample application.
