|
| 1 | +This document describes using the [QAI AppBuilder](../qai-appbuilder) Python API to perform inference with the [ConvNext-Tiny](https://aihub.qualcomm.com/models/convnext_tiny) |
| 2 | +target recognition model using Qualcomm® Hexagon™ Processor (NPU). |
| 3 | + |
| 4 | +**Supported Devices** |
| 5 | + |
| 6 | +| Device | SoC | |
| 7 | +| ---------- | ------- | |
| 8 | +| Dragon Q6A | QCS6490 | |
| 9 | + |
| 10 | +## Install QAI AppBuilder |
| 11 | + |
| 12 | +:::tip |
| 13 | + |
| 14 | +1. Please install QAI AppBuilder according to [**QAI AppBuilder Installation Guide**](../qai-appbuilder). |
| 15 | + |
| 16 | +2. Please configure QAIRT environment variables according to [**Configure QAIRT Environment Variables**](../qai-appbuilder). |
| 17 | + ::: |
| 18 | + |
| 19 | +## Run Example |
| 20 | + |
| 21 | +### Install Dependencies |
| 22 | + |
| 23 | +<NewCodeBlock tip="Device" type="device"> |
| 24 | + |
| 25 | +```bash |
| 26 | +pip3 install requests tqdm qai-hub py3_wget opencv-python torch torchvision |
| 27 | +``` |
| 28 | + |
| 29 | +</NewCodeBlock> |
| 30 | + |
| 31 | +### Run Script |
| 32 | + |
| 33 | +- Navigate to the example directory |
| 34 | + |
| 35 | + <Tabs> |
| 36 | + |
| 37 | + <TabItem value="QCS6490"> |
| 38 | + |
| 39 | + <NewCodeBlock tip="Device" type="device"> |
| 40 | + |
| 41 | + ```bash |
| 42 | + cd ai-engine-direct-helper/samples/linux/python |
| 43 | + ``` |
| 44 | + |
| 45 | + </NewCodeBlock> |
| 46 | + |
| 47 | + </TabItem> |
| 48 | + |
| 49 | + </Tabs> |
| 50 | + |
| 51 | +- Prepare input image, using the following image as input example |
| 52 | + |
| 53 | + {" "} |
| 54 | + |
| 55 | + <div style={{ textAlign: "center" }}> |
| 56 | + <img src="/en/img/dragon/q6a/test_image.webp" style={{ width: "65%" }} /> |
| 57 | + input image |
| 58 | + </div> |
| 59 | + |
| 60 | +- Execute inference |
| 61 | + |
| 62 | + <NewCodeBlock tip="Device" type="device"> |
| 63 | + |
| 64 | + ```bash |
| 65 | + python3 convnext_tiny/convnext_tiny.py |
| 66 | + ``` |
| 67 | + |
| 68 | + </NewCodeBlock> |
| 69 | + |
| 70 | + ```bash |
| 71 | + $ python3 convnext_tiny/convnext_tiny.py |
| 72 | + Current file directory: /mnt/ssd/qualcomm/701/zzf_fork/ai-engine-direct-helper/samples/linux/python/convnext_tiny |
| 73 | + 0.0ms [WARNING] <W> Initializing HtpProvider |
| 74 | + |
| 75 | + /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.4.0/ipc/fastrpc/rpcmem/src/rpcmem_android.c:38:dummy call to rpcmem_init, rpcmem APIs will be used from libxdsprpc |
| 76 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 77 | + |
| 78 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 79 | + |
| 80 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 81 | + |
| 82 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 83 | + |
| 84 | + 132.1ms [WARNING] Time: Read model file to memory. 15.88 |
| 85 | + |
| 86 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 87 | + |
| 88 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 89 | + |
| 90 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 91 | + |
| 92 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 93 | + |
| 94 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 95 | + |
| 96 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 97 | + |
| 98 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 99 | + |
| 100 | + 176.1ms [WARNING] Time: contextCreateFromBinary. 44.01 |
| 101 | + |
| 102 | + 176.2ms [WARNING] Time: UnmapViewOfFile. 0.00 |
| 103 | + |
| 104 | + 176.6ms [WARNING] Time: model_initialize convnext_tiny 176.53 |
| 105 | + |
| 106 | + 245.2ms [WARNING] Time: model_inference convnext_tiny 11.95 |
| 107 | + |
| 108 | + Top 5 predictions for image: |
| 109 | + |
| 110 | + Samoyed 0.637629509 |
| 111 | + Pomeranian 0.1382825226 |
| 112 | + keeshond 0.0217001885 |
| 113 | + Arctic fox 0.0138142202 |
| 114 | + white wolf 0.0115938596 |
| 115 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 116 | + |
| 117 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 118 | + |
| 119 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 120 | + |
| 121 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 122 | + |
| 123 | + /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.4.0/ipc/fastrpc/rpcmem/src/rpcmem_android.c:42:dummy call to rpcmem_deinit, rpcmem APIs will be used from libxdsprpc |
| 124 | + 263.1ms [WARNING] Time: model_destroy convnext_tiny 15.29 |
| 125 | + ``` |
| 126 | + |
| 127 | + The printed results show that `Samoyed` has the highest confidence, which matches the input image content. |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## English Translation (For Review) |
| 132 | + |
| 133 | +This document describes using the [QAI AppBuilder](../qai-appbuilder) Python API to perform inference with the [ConvNext-Tiny](https://aihub.qualcomm.com/models/convnext_tiny) |
| 134 | +target recognition model using Qualcomm® Hexagon™ Processor (NPU). |
| 135 | + |
| 136 | +**Supported Devices** |
| 137 | + |
| 138 | +| Device | SoC | |
| 139 | +| ---------- | ------- | |
| 140 | +| Dragon Q6A | QCS6490 | |
| 141 | + |
| 142 | +## Install QAI AppBuilder |
| 143 | + |
| 144 | +:::tip |
| 145 | + |
| 146 | +1. Please install QAI AppBuilder according to [**QAI AppBuilder Installation Guide**](../qai-appbuilder#installation-methods). |
| 147 | + |
| 148 | +2. Please configure QAIRT environment variables according to [**Configure QAIRT Environment Variables**](../qai-appbuilder#configure-qairt-environment-variables). |
| 149 | + ::: |
| 150 | + |
| 151 | +## Run Example |
| 152 | + |
| 153 | +### Install Dependencies |
| 154 | + |
| 155 | +<NewCodeBlock tip="Device" type="device"> |
| 156 | + |
| 157 | +```bash |
| 158 | +pip3 install requests tqdm qai-hub py3_wget opencv-python torch torchvision |
| 159 | +``` |
| 160 | + |
| 161 | +</NewCodeBlock> |
| 162 | + |
| 163 | +### Run Script |
| 164 | + |
| 165 | +- Navigate to the example directory |
| 166 | + |
| 167 | + <Tabs> |
| 168 | + |
| 169 | + <TabItem value="QCS6490"> |
| 170 | + |
| 171 | + <NewCodeBlock tip="Device" type="device"> |
| 172 | + |
| 173 | + ```bash |
| 174 | + cd ai-engine-direct-helper/samples/linux/python |
| 175 | + ``` |
| 176 | + |
| 177 | + </NewCodeBlock> |
| 178 | + |
| 179 | + </TabItem> |
| 180 | + |
| 181 | + </Tabs> |
| 182 | + |
| 183 | +- Prepare input image, using the following image as input example |
| 184 | + |
| 185 | + {" "} |
| 186 | + |
| 187 | + <div style={{ textAlign: "center" }}> |
| 188 | + <img src="/en/img/dragon/q6a/test_image.webp" style={{ width: "65%" }} /> |
| 189 | + input image |
| 190 | + </div> |
| 191 | + |
| 192 | +- Execute inference |
| 193 | + |
| 194 | + <NewCodeBlock tip="Device" type="device"> |
| 195 | + |
| 196 | + ```bash |
| 197 | + python3 convnext_tiny/convnext_tiny.py |
| 198 | + ``` |
| 199 | + |
| 200 | + </NewCodeBlock> |
| 201 | + |
| 202 | + ```bash |
| 203 | + $ python3 convnext_tiny/convnext_tiny.py |
| 204 | + Current file directory: /mnt/ssd/qualcomm/701/zzf_fork/ai-engine-direct-helper/samples/linux/python/convnext_tiny |
| 205 | + 0.0ms [WARNING] <W> Initializing HtpProvider |
| 206 | + |
| 207 | + /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.4.0/ipc/fastrpc/rpcmem/src/rpcmem_android.c:38:dummy call to rpcmem_init, rpcmem APIs will be used from libxdsprpc |
| 208 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 209 | + |
| 210 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 211 | + |
| 212 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 213 | + |
| 214 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 215 | + |
| 216 | + 132.1ms [WARNING] Time: Read model file to memory. 15.88 |
| 217 | + |
| 218 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 219 | + |
| 220 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 221 | + |
| 222 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 223 | + |
| 224 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 225 | + |
| 226 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 227 | + |
| 228 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 229 | + |
| 230 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 231 | + |
| 232 | + 176.1ms [WARNING] Time: contextCreateFromBinary. 44.01 |
| 233 | + |
| 234 | + 176.2ms [WARNING] Time: UnmapViewOfFile. 0.00 |
| 235 | + |
| 236 | + 176.6ms [WARNING] Time: model_initialize convnext_tiny 176.53 |
| 237 | + |
| 238 | + 245.2ms [WARNING] Time: model_inference convnext_tiny 11.95 |
| 239 | + |
| 240 | + Top 5 predictions for image: |
| 241 | + |
| 242 | + Samoyed 0.637629509 |
| 243 | + Pomeranian 0.1382825226 |
| 244 | + keeshond 0.0217001885 |
| 245 | + Arctic fox 0.0138142202 |
| 246 | + white wolf 0.0115938596 |
| 247 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 248 | + |
| 249 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 250 | + |
| 251 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 252 | + |
| 253 | + 0.0ms [WARNING] <W> This META does not have Alloc2 Support |
| 254 | + |
| 255 | + /prj/qct/webtech_scratch20/mlg_user_admin/qaisw_source_repo/rel/qairt-2.37.1/point_release/SNPE_SRC/avante-tools/prebuilt/dsp/hexagon-sdk-5.4.0/ipc/fastrpc/rpcmem/src/rpcmem_android.c:42:dummy call to rpcmem_deinit, rpcmem APIs will be used from libxdsprpc |
| 256 | + 263.1ms [WARNING] Time: model_destroy convnext_tiny 15.29 |
| 257 | + ``` |
| 258 | + |
| 259 | + The printed results show that `Samoyed` has the highest confidence, which matches the input image content. |
| 260 | + |
| 261 | +``` |
| 262 | +
|
| 263 | +``` |
0 commit comments