This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
|
products:sbc:edge-2l:npu:rknn-sdk-quick-start [2026/05/31 22:59] nick |
products:sbc:edge-2l:npu:rknn-sdk-quick-start [2026/05/31 23:55] (current) nick [Run RKNN Python demo] |
||
|---|---|---|---|
| Line 10: | Line 10: | ||
| * rknn model zoo: 2.3.2 | * rknn model zoo: 2.3.2 | ||
| - | ==== Download RKNN related repositories ==== | + | ==== Download RKNN related repositories |
| It is recommended to create a new directory to store the RKNN repositories. For example, create a folder named '' | It is recommended to create a new directory to store the RKNN repositories. For example, create a folder named '' | ||
| Line 26: | Line 26: | ||
| ``` | ``` | ||
| - | ==== Install the RKNN-Toolkit2 environment on your host PC ==== | + | ==== Install the RKNN-Toolkit2 environment on your Host PC ==== |
| - | === Install Python === | + | === Install Python |
| If the Python 3.8 environment is not installed on your system, or if there are multiple versions of Python installed, it is recommended to use Miniforge Conda to create a new Python 3.8 environment. | If the Python 3.8 environment is not installed on your system, or if there are multiple versions of Python installed, it is recommended to use Miniforge Conda to create a new Python 3.8 environment. | ||
| - | === Install Miniforge Conda === | + | === Install Miniforge Conda - Host PC === |
| Download the Miniforge Conda installer from the following link: | Download the Miniforge Conda installer from the following link: | ||
| Line 43: | Line 43: | ||
| $ bash Miniforge3-Linux-x86_64.sh | $ bash Miniforge3-Linux-x86_64.sh | ||
| ``` | ``` | ||
| - | === Create Python environment using miniforge conda === | + | === Create Python environment using miniforge conda - Host PC === |
| In the terminal window on the computer, execute the following command to switch to the Miniforge conda base | In the terminal window on the computer, execute the following command to switch to the Miniforge conda base | ||
| environment: | environment: | ||
| Line 57: | Line 57: | ||
| $ conda activate py38Toolkit2.3.2 | $ conda activate py38Toolkit2.3.2 | ||
| ``` | ``` | ||
| - | === Install RKNN-Toolkit2 === | + | === Install RKNN-Toolkit2 |
| Install via local wheel packag. | Install via local wheel packag. | ||
| Line 66: | Line 66: | ||
| ``` | ``` | ||
| - | === Check if the RKNN-Toolkit2 | + | === Check if the RKNN-Toolkit2 |
| Switch to Python interactive mode | Switch to Python interactive mode | ||
| ```shell | ```shell | ||
| Line 135: | Line 135: | ||
| === Linux === | === Linux === | ||
| - | Running on a Ubuntu 24.04 system. | + | Running on a Ubuntu 24.04 system |
| Download the model zoo to your Edge 2L: | Download the model zoo to your Edge 2L: | ||
| Line 147: | Line 147: | ||
| ```shell | ```shell | ||
| sudo apt update | sudo apt update | ||
| - | sudo apt install python3-venv -y | + | sudo apt install python3.12-venv -y |
| ``` | ``` | ||
| Line 181: | Line 181: | ||
| ``` | ``` | ||
| - | Copy the converted model in [[# | + | Copy the converted model in [[#model-conversion | Model conversion]] to your Edge 2L: |
| ```shell | ```shell | ||
| adb push examples/ | adb push examples/ | ||
| + | ``` | ||
| + | |||
| + | Modify the demo code: | ||
| + | |||
| + | ```diff | ||
| + | diff --git a/ | ||
| + | index 21b4132..46b24d4 100644 | ||
| + | --- a/ | ||
| + | +++ b/ | ||
| + | @@ -1,5 +1,5 @@ | ||
| + | -from rknn.api import RKNN | ||
| + | - | ||
| + | +from rknnlite.api import RKNNLite as RKNN | ||
| + | +import numpy as np | ||
| + | |||
| + | class RKNN_model_container(): | ||
| + | def __init__(self, | ||
| + | @@ -9,10 +9,7 @@ class RKNN_model_container(): | ||
| + | | ||
| + | |||
| + | | ||
| + | - if target==None: | ||
| + | - ret = rknn.init_runtime() | ||
| + | - else: | ||
| + | - ret = rknn.init_runtime(target=target, | ||
| + | + ret = rknn.init_runtime() | ||
| + | if ret != 0: | ||
| + | | ||
| + | | ||
| + | @@ -33,10 +30,12 @@ class RKNN_model_container(): | ||
| + | else: | ||
| + | | ||
| + | |||
| + | + inputs = [np.expand_dims(item, | ||
| + | + | ||
| + | | ||
| + | |||
| + | | ||
| + | |||
| + | def release(self): | ||
| + | | ||
| + | - self.rknn = None | ||
| + | \ No newline at end of file | ||
| + | + self.rknn = None | ||
| + | (myenv312) khadas@Khadas: | ||
| ``` | ``` | ||
| Line 195: | Line 240: | ||
| {{: | {{: | ||
| + | |||
| + | Deactivate the python virtual enviranment: | ||
| + | |||
| + | ```shell | ||
| + | (myenv312) khadas@Khadas: | ||
| + | ``` | ||