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

# Run a Sample Application with a custom-trained model

> Integrate custom model with sample application.

This guide explains how to modify an existing Qualcomm IM SDK reference application to work with a custom-trained model. It uses a custom-trained YOLOv8 model as an example.

## Use a custom-trained YOLOv8 LiteRT model

Qualcomm IM SDK reference applications use the YOLOv8 model for object detection. This example explains how to run a custom-trained YOLOv8 variant with the current reference application.

To run your own custom-trained YOLOv8 model, complete the following steps:

1. Replace the existing model with your new model in the reference application.
2. Update the label files with your custom labels.
3. Run the reference application with the updated model.

### Update the label files

The Qualcomm IM SDK reference applications expect labels in JSON format. Update the `id`, `color`, and `label` values for each entry in the labels file.

The format for each label entry is:

```json theme={null}
[
  {"id": 0, "color": "0x00FF00FF", "label": "person"}
]
```

For example:

```json theme={null}
[
  {"id": 0, "color": "0x00FF00FF", "label": "person"},
  {"id": 1, "color": "0x00FF00FF", "label": "bicycle"},
  {"id": 2, "color": "0x0000FFFF", "label": "car"},
  {"id": 3, "color": "0x00FF00FF", "label": "motorcycle"}
]
```

### Run object detection with the custom model

To run object detection using the LiteRT runtime with your custom model and label files, complete the following steps:

1. On the host computer, set the user environment variable:

   ```shell theme={null}
   export USER=root
   ```

2. Copy the model to the device:

   ```shell theme={null}
   scp yolov8_custom.tflite $USER@<IP_ADDRESS_OF_TARGET_DEVICE>:/etc/models/
   ```

3. Copy the label file to the device:

   ```shell theme={null}
   scp yolov8_custom.json $USER@<IP_ADDRESS_OF_TARGET_DEVICE>:/etc/labels/
   ```

4. Sign in to the device using SSH:

   ```shell theme={null}
   ssh $USER@<IP_ADDRESS_OF_TARGET_DEVICE>
   ```

5. Edit the `/etc/configs/config_detection.json` configuration file:

   ```json theme={null}
   {
     "file-path": "/etc/media/video.mp4",
     "ml-framework": "tflite",
     "yolo-model-type": "yolov8",
     "model": "/etc/models/yolov8_custom.tflite",
     "labels": "/etc/labels/yolov8_custom.json",
     "threshold": 40,
     "runtime": "dsp"
   }
   ```

6. Run the sample application:

   ```shell theme={null}
   gst-ai-object-detection --config-file=/etc/configs/config_detection.json
   ```

## Notes

* To display all available options, run:

  ```shell theme={null}
  gst-ai-object-detection -h
  ```

* To stop the application, press `Ctrl+C`.
