# Chạy ứng dụng mẫu bằng model được huấn luyện tùy chỉnh

Ứng dụng mẫu sẽ sử dụng model YoloV8 được huấn luyện tùy chỉnh làm ví dụ.

Điều kiện tiên quyết

1. Thiết lập SDK có thể mở rộng (eSDK) để phát triển mã ứng dụng/plugin.

    Hãy xem [Hướng dẫn bắt đầu nhanh với Qualcomm Intelligent Multimedia Software Development Kit (IM SDK)](https://docs.qualcomm.com/bundle/publicresource/topics/80-70020-51/introduction.html) để biết hướng dẫn về cách thiết lập eSDK cũng như cách tải xuống và biên dịch mã nguồn.
2. Hãy xem [Phát triển ứng dụng AI/ML của riêng bạn](https://docs.qualcomm.com/doc/80-70020-15BV/topic/develop-your-own-application.html) để biết hướng dẫn về cách tải mã nguồn xuống và biên dịch ứng dụng tham chiếu tùy chỉnh.
3. [Tải xuống model và tệp nhãn cho Qualcomm Neural Processing SDK](https://docs.qualcomm.com/doc/80-70020-15BV/topic/classify-objects-with-default-model.html#download-model-files).

## Sử dụng model YoloV8 LiteRT được huấn luyện tùy chỉnh

Ứng dụng tham chiếu của Qualcomm IM SDK sử dụng model YoloV8 để phát hiện đối tượng. Ví dụ này giải thích cách bạn có thể dùng thử một biến thể YoloV8 được huấn luyện tùy chỉnh.

Hãy làm theo các bước sau đây để chạy model YoloV8 được huấn luyện tùy chỉnh của riêng bạn với ứng dụng tham chiếu hiện tại.

1. Thay thế model hiện có bằng model mới trong ứng dụng mẫu.
2. Sửa đổi tệp nhãn bằng nhãn tùy chỉnh.
3. Chạy ứng dụng mẫu với model đã sửa đổi.

### Sửa đổi nhãn

Khi dùng Qualcomm IM SDK và ứng dụng tham chiếu, ứng dụng yêu cầu nhãn có định dạng cụ thể. Bạn cần cập nhật các giá trị `<label_name>`, `<hex_value_for_label_id>` và `<hex_value_for_color>` cho từng nhãn trong tệp nhãn này.

Định dạng của từng nhãn trong tệp nhãn phải theo mẫu bên dưới.

(structure)"<label_name>,id=(guint)<hex_value_for_label_id>,color=(guint)<hex_value_for_color>;"
    Copy to clipboard

Ví dụ:

(structure)"person,id=(guint)0x0,color=(guint)0x00FF00FF;"
    (structure)"bicycle,id=(guint)0x1,color=(guint)0x00FF00FF;"
    (structure)"car,id=(guint)0x2,color=(guint)0x0000FFFF;"
    (structure)"motorcycle,id=(guint)0x3,color=(guint)0x00FF00FF;"
    Copy to clipboard

### Chạy tính năng phát hiện đối tượng bằng model tùy chỉnh

Để chạy model phát hiện đối tượng bằng runtime LiteRT, hãy chỉ định model được huấn luyện tùy chỉnh cùng với tệp nhãn tùy chỉnh trong tham số dòng lệnh rồi chạy các lệnh sau.

1. Sao chép model sang thiết bị.

scp yolov8_custom.tflite root@<IP address of the target device>:/etc/models/
        Copy to clipboard
2. Sao chép nhãn sang thiết bị.

scp yolov8_custom.labels root@<IP address of the target device>:/etc/labels/
        Copy to clipboard
3. Đăng nhập vào thiết bị.

ssh root@<IP address of the target device>
        Copy to clipboard
4. Sửa đổi tệp `/etc/configs/config_detection.json` như bên dưới.

{
        "file-path": "/etc/media/video.mp4",
        "ml-framework": "tflite",
        "yolo-model-type": "yolov8",
        "model": "/etc/models/yolov8_custom.tflite",
        "labels": "/etc/labels/yolov8_custom.labels",
        "constants": "<constants for custom YOLOv8 model>",
        "threshold": 40,
        "runtime": "dsp"
        }
        Copy to clipboard
5. Bật dịch vụ Weston bằng cách chạy lệnh bên dưới:

export XDG_RUNTIME_DIR=/dev/socket/weston && export WAYLAND_ DISPLAY=wayland-1
        Copy to clipboard
6. Chạy ứng dụng mẫu.

gst-ai-object-detection --config-file=/etc/configs/config_detection.json
        Copy to clipboard

Ghi chú

- Để hiển thị các tùy chọn trợ giúp sẵn có, hãy chạy lệnh sau:

gst-ai-object-detection -h
        Copy to clipboard
- Để dừng use case, hãy nhấn <kbd class="kbd compound docutils literal notranslate"><kbd class="kbd docutils literal notranslate">CTRL</kbd>+<kbd class="kbd docutils literal notranslate">C</kbd></kbd>.

Last Published: Dec 23, 2025

[Previous Topic
Phân loại đối tượng bằng model mặc định](https://docs.qualcomm.com/bundle/publicresource/80-70020-15BV/topics/classify-objects-with-default-model.md) [Next Topic
Chạy ứng dụng mẫu bằng Qualcomm Device Cloud](https://docs.qualcomm.com/bundle/publicresource/80-70020-15BV/topics/sample-app-qdc.md)