Quickstart for beginners

This short introduction use kp to build simple edge AI application by following steps:

  1. Connect Kneron device
  2. Upload SCPU/NCPU firmware
  3. Upload NEF model
  4. Inference image

Note 1: Please using pip to install kp API and opencv-python before the following tutorial. See the Installation for details.

Note 2: Please using kneronDFUT to upgrade firmware from KDP to KDP2 before the following tutorial. See the Upgrade AI Device to KDP2 for details.

Import kp and cv2 into your program:

import kp
import cv2

Get one Kneron device USB port ID for connecting:

device_descriptors = kp.core.scan_devices()

if 0 < device_descriptors.device_descriptor_number:
    usb_port_id = device_descriptors.device_descriptor_list[0].usb_port_id
    print('Error: no Kneron device connect.')

Connect the device and get Kneron device handler (Device Group):

device_group = kp.core.connect_devices(usb_port_ids=[usb_port_id])

Set timeout of the USB communication (Default: infinity wait):


Upload firmware to Kneron device:

Please replace SCPU_FW_PATH, NCPU_FW_PATH by fw_scpu.bin and fw_ncpu.bin path (Please find target device firmware under res/firmware folder)

SCPU_FW_PATH = 'res/firmware/KL520/fw_scpu.bin'
NCPU_FW_PATH = 'res/firmware/KL520/fw_ncpu.bin'

Upload NEF model to Kneron device:

Please replace MODEL_FILE_PATH by models_520.nef path (Please find target device NEF model under res/models folder)

MODEL_FILE_PATH = 'res/models/KL520/tiny_yolo_v3/models_520.nef'
model_nef_descriptor = kp.core.load_model_from_file(device_group=device_group,

Inference image: