使用 Orange Pi AIpro开发板基于 YOLOv8 进行USB 摄像头实时目标检测


简介

在这里插入图片描述

官网:Orange-Pi-AIpro

算力指标与概念

TOPS是每秒数万亿或万亿次操作。它主要是衡量可实现的最大吞吐量,而不是实际吞吐量的衡量标准。大多数操作是 MAC(multiply/accumulates),因此:

                     TOPS =(MAC 单元数)x(MAC 操作频率)x 2

目前我手里拿到的是NPU 8 T 算力的版本,她是否能够胜任计算机视觉领域目前最火爆的目标检测任务呢?

香橙派 AIpro NPU 纸面算力直观了解

找到了一个帖子

  • https://www.hiascend.com/forum/thread-0281143834564881056-1-1.html

在这里插入图片描述


纸面上,该资料给出的YOLOv8n 量化后跑到了每85 帧秒,我也没博主贴代码和参数,有个感觉就行。可能是低分辨率下最理想状态,下面我们来手把手叫你进行目标检测。


手把手教你开机与基本配置

首先当然是基本的配置。

开机存储挂载设置

开机时候发现,有个状态知识灯没亮

在这里插入图片描述


查阅手册发现应该是启动状态对应的存储不对。

在这里插入图片描述

拨回到右右状态,完成启动

在这里插入图片描述


这样我们就能SSH 连上看到界面啦!

在这里插入图片描述

风扇设置

实际使用过程中,发现板子在推理的时候温度还是比较高的,我们可以对风扇进行设置

实际操作
在 /opt/opi_test/fan 目录下有两个与风扇风速相关的脚本,可以尝试执行,并结合昇腾文档就比较好理解。
当开发板发烫,可以控制风扇的风速操作是:

# 设置为手动模式
sudo npu-smi set -t pwm-mode -d 0
# 设置风速(最后那个100表示调到最大,0风速停止工作。60 冷却效果就很好了)
sudo npu-smi set -t pwm-duty-ratio -d 60
# 当温度正常时再设置为自动模型
sudo npu-smi set -t pwm-mode -d 1

使用 Orange Pi AIpro进行YOLOv8 目标检测

我们不用docker 安装 ,而是直接新建 新的conda 环境 基于ultralytics 安装 yolov8

conda create -n yolov8 python=3.10 -y
pip install ultralytics  
Downloading oauthlib-3.2.2-py3-none-any.whl (151 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 151.7/151.7 kB 3.4 MB/s eta 0:00:00
Downloading pyasn1-0.6.0-py2.py3-none-any.whl (85 kB)
   ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 85.3/85.3 kB 2.0 MB/s eta 0:00:00
Building wheels for collected packages: coremltools, psutil
  Building wheel for coremltools (setup.py) ... done
  Created wheel for coremltools: filename=coremltools-7.2-py3-none-any.whl size=1595684 sha256=6e1dcdddd15f175ed8ef3d40ef4598f536bc311f0ea2ef031868f8ba618a539c
  Stored in directory: /home/HwHiAiUser/.cache/pip/wheels/38/4a/65/6672923cb40a07330ab25e088dd6db86999907ababe8b8c398
  Building wheel for psutil (pyproject.toml) ... done
  Created wheel for psutil: filename=psutil-5.9.8-cp310-abi3-linux_aarch64.whl size=242067 sha256=636376e201c03ba1304b856b693430eeeb19c912aa7427e15d8f71a0ddb717bd
  Stored in directory: /home/HwHiAiUser/.cache/pip/wheels/3e/93/d6/85cd469d2103627a9e38acdccc834a9997e77d2abe6da25c8b
Successfully built coremltools psutil
Installing collected packages: pytz, py-cpuinfo, openvino-telemetry, mpmath, libclang, flatbuffers, wrapt, urllib3, tzdata, typing-extensions, tqdm, termcolor, tensorflow-io-gcs-filesystem, tensorflow-estimator, tensorboard-data-server, sympy, six, pyyaml, pyparsing, pyasn1, psutil, protobuf, pillow, oauthlib, numpy, networkx, MarkupSafe, markdown, kiwisolver, keras, idna, grpcio, gast, fsspec, fonttools, filelock, exceptiongroup, cycler, charset-normalizer, certifi, cachetools, attrs, absl-py, werkzeug, tensorflow-hub, scipy, rsa, requests, python-dateutil, pyasn1-modules, pyaml, packaging, opt-einsum, opencv-python, onnx, jinja2, h5py, google-pasta, contourpy, cattrs, astunparse, torch, requests-oauthlib, pandas, openvino, matplotlib, google-auth, coremltools, torchvision, thop, seaborn, google-auth-oauthlib, ultralytics, tensorboard, tensorflow-cpu-aws, tensorflow, tensorflowjs


ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
auto-tune 0.1.0 requires decorator, which is not installed.
op-compile-tool 0.1.0 requires getopt, which is not installed.
op-compile-tool 0.1.0 requires inspect, which is not installed.
op-compile-tool 0.1.0 requires multiprocessing, which is not installed.
opc-tool 0.1.0 requires decorator, which is not installed.
schedule-search 0.0.1 requires decorator, which is not installed.
te 0.4.0 requires cloudpickle, which is not installed.
te 0.4.0 requires decorator, which is not installed.
te 0.4.0 requires synr==0.5.0, which is not installed.
te 0.4.0 requires tornado, which is not installed.
Successfully installed MarkupSafe-2.1.5 absl-py-2.1.0 astunparse-1.6.3 attrs-23.2.0 cachetools-5.3.3 cattrs-23.2.3 certifi-2024.2.2 charset-normalizer-3.3.2 contourpy-1.2.1 coremltools-7.2 cycler-0.12.1 exceptiongroup-1.2.1 filelock-3.14.0 flatbuffers-24.3.25 fonttools-4.51.0 fsspec-2024.5.0 gast-0.4.0 google-auth-2.29.0 google-auth-oauthlib-1.0.0 google-pasta-0.2.0 grpcio-1.64.0 h5py-3.10.0 idna-3.7 jinja2-3.1.4 keras-2.13.1 kiwisolver-1.4.5 libclang-18.1.1 markdown-3.6 matplotlib-3.9.0 mpmath-1.3.0 networkx-3.3 numpy-1.23.5 oauthlib-3.2.2 onnx-1.16.0 opencv-python-4.9.0.80 openvino-2024.1.0 openvino-telemetry-2024.1.0 opt-einsum-3.3.0 packaging-20.9 pandas-2.2.2 pillow-10.3.0 protobuf-3.20.3 psutil-5.9.8 py-cpuinfo-9.0.0 pyaml-24.4.0 pyasn1-0.6.0 pyasn1-modules-0.4.0 pyparsing-3.1.2 python-dateutil-2.9.0.post0 pytz-2024.1 pyyaml-6.0.1 requests-2.32.2 requests-oauthlib-2.0.0 rsa-4.9 scipy-1.13.0 seaborn-0.13.2 six-1.16.0 sympy-1.12 tensorboard-2.13.0 tensorboard-data-server-0.7.2 tensorflow-2.13.1 tensorflow-cpu-aws-2.13.1 tensorflow-estimator-2.13.0 tensorflow-hub-0.12.0 tensorflow-io-gcs-filesystem-0.37.0 tensorflowjs-3.18.0 termcolor-2.4.0 thop-0.1.1.post2209072238 torch-2.1.2 torchvision-0.16.2 tqdm-4.66.4 typing-extensions-4.5.0 tzdata-2024.1 ultralytics-8.2.19 urllib3-2.2.1 werkzeug-3.0.3 wrapt-1.16.0

安装好后,有一些报错,简单测试一下,反正 能跑


Python 3.10.14 (main, May  6 2024, 19:36:58) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ultralytics import YOLO
>>> model=YOLO(r'/data/yolov8n.pt')
>>> model.info()
YOLOv8n summary: 225 layers, 3157200 parameters, 0 gradients, 8.9 GFLOPs
(225, 3157200, 0, 8.8575488)
>>> exit()

Pytorch pt 格式直接推理

我们找一段程序,使用yolov8 进行目标检测推理,并在屏幕上显示FPS

import cv2
from ultralytics import YOLO
from cv2 import getTickCount, getTickFrequency
# 加载 YOLOv8 模型
model = YOLO("weights/yolov8s.pt")

# 获取摄像头内容,参数 0 表示使用默认的摄像头
cap = cv2.VideoCapture(0)

while cap.isOpened():
    loop_start = getTickCount()
    success, frame = cap.read()  # 读取摄像头的一帧图像

    if success:
        results = model.predict(source=frame) # 对当前帧进行目标检测并显示结果
    annotated_frame = results[0].plot()

    # 中间放自己的显示程序
    loop_time = getTickCount() - loop_start
    total_time = loop_time / (getTickFrequency())
    FPS = int(1 / total_time)
    # 在图像左上角添加FPS文本
    fps_text = f"FPS: {FPS:.2f}"
    font = cv2.FONT_HERSHEY_SIMPLEX
    font_scale = 1
    font_thickness = 2
    text_color = (0, 0, 255)  # 红色
    text_position = (10, 30)  # 左上角位置

    cv2.putText(annotated_frame, fps_text, text_position, font, font_scale, text_color, font_thickness)
    cv2.imshow('img', annotated_frame)
    # 通过按下 'q' 键退出循环
    if cv2.waitKey(1) & 0xFF == ord('q'):
        break

cap.release()  # 释放摄像头资源
cv2.destroyAllWindows()  # 关闭OpenCV窗口


可见,使用CPU 进行推理 ,运行效果缓慢,每秒只有1帧

在这里插入图片描述


NCNN 格式推理

接下来,为了加速推理,我们看看低成本的折腾一下 NCNN 的效果怎么样,先说结论,从官方文档看,至少应该有5倍左右的速度提升。

总体包含3个步骤如下

0.配置ncnn

首先安装

pip install ncnn

如果直接让 ultralytics yolov8 运行时候安装容易出错

(yolov8) HwHiAiUser@orangepiaipro:/data$ python
Python 3.10.14 (main, May  6 2024, 19:36:58) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ultralytics import YOLO
>>> model = YOLO("yolov8n.pt")
>>> model.export(format="ncnn")
Ultralytics YOLOv8.2.19 🚀 Python-3.10.14 torch-2.1.2 CPU (aarch64)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs

PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and o                                                                                                                              utput shape(s) (1, 84, 8400) (6.2 MB)

TorchScript: starting export with torch 2.1.2...
TorchScript: export success7.6s, saved as 'yolov8n.torchscript' (12.4 MB)
requirements: Ultralytics requirement ['ncnn'] not found, attempting AutoUpdate.                                                                                                                              ..
ERROR: Exception:
Traceback (most recent call last):
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 438, in _error_catcher
    yield
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 561, in read
    data = self._fp_read(amt) if not fp_closed else b""
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 527, in _fp_read
    return self._fp.read(amt) if amt is not None else self._fp.read()
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/http/client.py", line                                                                                                                               466, in read
    s = self.fp.read(amt)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/socket.py", line 705,                                                                                                                               in readinto
    return self._sock.recv_into(b)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/ssl.py", line 1307, i                                                                                                                              n recv_into
    return self.read(nbytes, buffer)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/ssl.py", line 1163, i                                                                                                                              n read
    return self._sslobj.read(len, buffer)
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/cli/base_command.py", line 180, in exc_logging_wrapper
    status = run_func(*args)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/cli/req_command.py", line 245, in wrapper
    return func(self, options, args)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/commands/install.py", line 377, in run
    requirement_set = resolver.resolve(
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/resolution/resolvelib/resolver.py", line 179, in resolve
    self.factory.preparer.prepare_linked_requirements_more(reqs)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/operations/prepare.py", line 552, in prepare_linked_requirements_more
    self._complete_partial_requirements(
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/operations/prepare.py", line 467, in _complete_partial_requirements
    for link, (filepath, _) in batch_download:
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/network/download.py", line 183, in __call__
    for chunk in chunks:
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/cli/progress_bars.py", line 53, in _rich_progress_bar
    for chunk in iterable:
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_in                                                                                                                              ternal/network/utils.py", line 63, in response_chunks
    for chunk in response.raw.stream(
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 622, in stream
    data = self.read(amt=amt, decode_content=decode_content)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 560, in read
    with self._error_catcher():
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/contextlib.py", line                                                                                                                               153, in __exit__
    self.gen.throw(typ, value, traceback)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/pip/_ve                                                                                                                              ndor/urllib3/response.py", line 443, in _error_catcher
    raise ReadTimeoutError(self._pool, None, "Read timed out.")
pip._vendor.urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='files                                                                                                                              .pythonhosted.org', port=443): Read timed out.
Retry 1/2 failed: Command 'pip install --no-cache-dir "ncnn" ' returned non-zero                                                                                                                               exit status 2.
requirements: AutoUpdate success ✅ 149.0s, installed 1 package: ['ncnn']
requirements: ⚠️ Restart runtime or rerun command for updates to take effect

NCNN: export failure ❌ 149.0s: No module named 'ncnn'
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultraly                                                                                                                              tics/engine/model.py", line 602, in export
    return Exporter(overrides=args, _callbacks=self.callbacks)(model=self.model)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/torch/u                                                                                                                              tils/_contextlib.py", line 115, in decorate_context
    return func(*args, **kwargs)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultraly                                                                                                                              tics/engine/exporter.py", line 320, in __call__
    f[11], _ = self.export_ncnn()
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultraly                                                                                                                              tics/engine/exporter.py", line 142, in outer_func
    raise e
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultraly                                                                                                                              tics/engine/exporter.py", line 137, in outer_func
    f, model = inner_func(*args, **kwargs)
  File "/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultraly                                                                                                                              tics/engine/exporter.py", line 534, in export_ncnn
    import ncnn  # noqa
ModuleNotFoundError: No module named 'ncnn'

1. 导出ncnn,下载pnnx 文件

https://github.com/pnnx/pnnx/releases/download/20240410/pnnx-20240410-linux-aarch64.zip

>>> from ultralytics import YOLO
>>> model = YOLO("yolov8n.pt")
>>> model.export(format="ncnn")
Ultralytics YOLOv8.2.19 🚀 Python-3.10.14 torch-2.1.2 CPU (aarch64)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs

PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)

TorchScript: starting export with torch 2.1.2...
TorchScript: export success7.2s, saved as 'yolov8n.torchscript' (12.4 MB)

NCNN: starting export with NCNN 1.0.20240410...
NCNN: WARNING ⚠️ PNNX not found. Attempting to download binary file from https://github.com/pnnx/pnnx/.
Note PNNX Binary file must be placed in current working directory or in /home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultralytics. See PNNX repo for full installation instructions.
NCNN: successfully found latest PNNX asset file pnnx-20240410-linux-aarch64.zip
Downloading https://github.com/pnnx/pnnx/releases/download/20240410/pnnx-20240410-linux-aarch64.zip to 'pnnx-20240410-linux-aarch64.zip'...

最后一次成功了,可见导出了是一个文件夹

Python 3.10.14 (main, May  6 2024, 19:36:58) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ultralytics import YOLO
>>> model = YOLO("yolov8n.pt")
>>> model.export(format="ncnn")
Ultralytics YOLOv8.2.19 🚀 Python-3.10.14 torch-2.1.2 CPU (aarch64)
YOLOv8n summary (fused): 168 layers, 3151904 parameters, 0 gradients, 8.7 GFLOPs

PyTorch: starting from 'yolov8n.pt' with input shape (1, 3, 640, 640) BCHW and output shape(s) (1, 84, 8400) (6.2 MB)

TorchScript: starting export with torch 2.1.2...
TorchScript: export success ✅ 7.3s, saved as 'yolov8n.torchscript' (12.4 MB)

NCNN: starting export with NCNN 1.0.20240410...
NCNN: WARNING ⚠️ PNNX not found. Attempting to download binary file from https://github.com/pnnx/pnnx/.
Note PNNX Binary file must be placed in current working directory or in /home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultralytics. See PNNX repo for full installation instructions.
NCNN: successfully found latest PNNX asset file pnnx-20240410-linux-aarch64.zip
Unzipping pnnx-20240410-linux-aarch64.zip to /data/pnnx-20240410-linux-aarch64...: 100%|██████████| 3/3 [00:00<00:00,  5.47file/s]
NCNN: running '/home/HwHiAiUser/.conda/envs/yolov8/lib/python3.10/site-packages/ultralytics/pnnx yolov8n.torchscript ncnnparam=yolov8n_ncnn_model/model.ncnn.param ncnnbin=yolov8n_ncnn_model/model.ncnn.bin ncnnpy=yolov8n_ncnn_model/model_ncnn.py pnnxparam=yolov8n_ncnn_model/model.pnnx.param pnnxbin=yolov8n_ncnn_model/model.pnnx.bin pnnxpy=yolov8n_ncnn_model/model_pnnx.py pnnxonnx=yolov8n_ncnn_model/model.pnnx.onnx fp16=0 device=cpu inputshape="[1, 3, 640, 640]"'
pnnxparam = yolov8n_ncnn_model/model.pnnx.param
pnnxbin = yolov8n_ncnn_model/model.pnnx.bin
pnnxpy = yolov8n_ncnn_model/model_pnnx.py
pnnxonnx = yolov8n_ncnn_model/model.pnnx.onnx
ncnnparam = yolov8n_ncnn_model/model.ncnn.param
ncnnbin = yolov8n_ncnn_model/model.ncnn.bin
ncnnpy = yolov8n_ncnn_model/model_ncnn.py
fp16 = 0
optlevel = 2
device = cpu
inputshape = [1,3,640,640]f32
inputshape2 =
customop =
moduleop =
############# pass_level0
inline module = ultralytics.nn.modules.block.Bottleneck
inline module = ultralytics.nn.modules.block.C2f
inline module = ultralytics.nn.modules.block.DFL
inline module = ultralytics.nn.modules.block.SPPF
inline module = ultralytics.nn.modules.conv.Concat
inline module = ultralytics.nn.modules.conv.Conv
inline module = ultralytics.nn.modules.head.Detect
inline module = ultralytics.nn.modules.block.Bottleneck
inline module = ultralytics.nn.modules.block.C2f
inline module = ultralytics.nn.modules.block.DFL
inline module = ultralytics.nn.modules.block.SPPF
inline module = ultralytics.nn.modules.conv.Concat
inline module = ultralytics.nn.modules.conv.Conv
inline module = ultralytics.nn.modules.head.Detect

----------------

############# pass_level1
############# pass_level2
############# pass_level3
############# pass_level4
############# pass_level5
############# pass_ncnn
NCNN: export success ✅ 6.5s, saved as 'yolov8n_ncnn_model' (12.2 MB)

Export complete (16.2s)
Results saved to /data
Predict:         yolo predict task=detect model=yolov8n_ncnn_model imgsz=640
Validate:        yolo val task=detect model=yolov8n_ncnn_model imgsz=640 data=coco.yaml
Visualize:       https://netron.app
'yolov8n_ncnn_model'

推理结果,可见NCNN推理方式能够提升5-10 倍的推理性能,我们用上面同样的代码,目前达到了 7 fps

2. 模型推理

from ultralytics import YOLO

# Load a YOLOv8n PyTorch model
model = YOLO("yolov8n.pt")

# Export the model to NCNN format
model.export(format="ncnn")  # creates 'yolov8n_ncnn_model'

# Load the exported NCNN model
ncnn_model = YOLO("yolov8n_ncnn_model")

# Run inference
results = ncnn_model("https://ultralytics.com/images/bus.jpg")

应该说,这个简单步骤操作下来,就能达到近实时的目标检测,这快板子CPU性能还是不错的!

在这里插入图片描述


是否可以使用Orange Pi AIpro 的 NPU 进行推理 呢?

什么是 NPU 呢?

在这里插入图片描述


NPU,是“神经网络处理单元”的缩写。NPU的工作原理是利用其专门设计的硬件结构来执行神经网络算法中的各种数学运算,如矩阵乘法、卷积等。这些运算是神经网络训练和推理过程中的核心操作。通过在硬件层面上进行优化,NPU能够以更低的能耗和更高的效率执行这些操作。

在这里插入图片描述


与CPU和GPU相比,NPU在以下几个方面具有明显优势:

  1. 性能:NPU针对AI计算进行了专门优化,能够提供更高的计算性能。

  2. 能效:NPU在执行AI任务时,通常比CPU和GPU更加节能。

  3. 面积效率:NPU的设计紧凑,能够在有限的空间内提供高效的计算能力。

  4. 专用硬件加速:NPU通常包含专门的硬件加速器,如张量加速器和卷积加速器,这些加速器能够显著提高AI任务的处理速度。

模型开发流程

基于香橙派AIpro开发AI推理应用^1,开发流程如下图所示,为了调用Orange Pi AIpro NPU的能力,看来我们需要AscendCL相关的知识!

在这里插入图片描述


模型转换

基于香橙派AIpro将开源框架模型转换为昇腾模型^2,这个ATC 中间层,就是上图中的AscendCL

在这里插入图片描述


根据上图,我们一般来说,只需要 做一下模型转换,然后 套用现有的推理代码就可以了

下面给出一个参考项目:

  • https://gitee.com/ascend/EdgeAndRobotics/tree/master/Samples/YOLOV5USBCamera

显然,使用Orange Pi AIpro 的 NPU 进行推理 YOLOv8 的推理也是可行的,而且速度应该会有更大的提升。

时间有限,基于此,我就不再展开了,且听下回分解!


结论

带有NPU 算力的下一代国产小型边缘端 开发板 Orange Pi AIpro 的算力足够让人惊艳,在计算机视觉越来越普及的今天,我们的边缘端设备能够直接承担行为分析,事件预警的重任,无疑可以给企业,个人创作更多的可能。

下一步,我打算好好学习利用一下这个开发版,针对大语言模型,多模态大模型,进行一定的部署尝试。希望我们的生态,终有一天能够比肩Ollama,实现一条命令部署大模型应用,创造无限可能!


参考文献

官网:Orange-Pi-AIpro
用户手册(没有在线地址):http://www.orangepi.cn/html/hardWare/computerAndMicrocontrollers/service-and-support/Orange-Pi-AIpro.html

参考官方链接

  • https://semiengineering.com/tops-memory-throughput-and-inference-efficiency/
  • 昇腾社区 技术干货
  • 香橙派 快速上手指南
  • 香橙派 学习资源导航
  • 华为昇腾 AI 市场应用案例
  • 华为昇腾论坛-香橙派

开机报错参考:

  • https://blog.csdn.net/snmper/article/details/136161555

高级指南

  • 部署大语言模型
  • NPU 命令参考指南

注释

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:/a/654210.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

干货!渗透测试入门教程!(建议收藏)

渗透测试是指从内网、外网等网络环境中&#xff0c;利用各种手段对某个特定网络进行模拟攻击&#xff0c;目的是为了寻找可能被利用的漏洞&#xff0c;是企业中重要的一环、 虽然大多数人在学习后都能快速上手&#xff0c;但渗透测试还是有一定的门槛&#xff0c;今天就给大家…

HashMap在Go与Java的底层实现与区别

在Java中 在Java中hash表的底层数据结构与扩容等已经是面试集合类问题中几乎必问的点了。网上有对源码的解析已经非常详细了我们这里还是说说其底层实现。 基础架构 public class HashMap<K,V> extends AbstractMap<K,V> implements Map<K,V>, Cloneable,…

JAVA云HIS医院系统源码 云HIS运维平台源码 融合B/S版电子病历系统,支持电子病历四级,saas模式

JAVA云HIS医院系统源码 云HIS运维平台源码 融合B/S版电子病历系统&#xff0c;支持电子病历四级&#xff0c;saas模式 HIS系统就是医院信息管理系统&#xff0c;HIS系统是整个医院信息化的核心&#xff0c;门诊、住院、药房、药库等都是由HIS系统来承载起来的&#xff0c;所以…

高动态范围成像(HDRI)技术在AI去衣中的革新作用

引言&#xff1a; 在计算机视觉和图像处理领域&#xff0c;人工智能&#xff08;AI&#xff09;去衣技术是一项颇具争议但又不容忽视的技术。它不仅在娱乐和多媒体制作领域中扮演着重要角色&#xff0c;还在时尚设计与电子商务中展现了其独特的价值。随着技术的不断进步&#x…

动态规划part02 Day42

LC62不同路径 LC63不同路径II(超时10min) 超时原因分析&#xff1a;思路想错了&#xff0c;即便是正确思路初始化也有点问题&#xff0c;应该将不必要的判断逻辑引入初始化的过程中初始化&#xff1a; 从左上角到[i][0]和[0][j]都只有一条路径dp[i][0]1和dp[0][j]1引入故障&am…

探索减轻 AI 说服伤害的机制方法

随着生成式人工智能&#xff08;AI&#xff09;系统在各个领域的广泛应用&#xff0c;其说服能力也日益增强&#xff0c;引发了对 AI 说服可能带来伤害的担忧。AI 说服的伤害不仅来源于说服的结果&#xff0c;还包括说服过程中可能对个体或社会造成的不利影响。为了系统性地研究…

信息抽取模型TPLinker

1.motivation 早期传统方法首先抽取实体再抽取它们之间的关系&#xff0c;但是忽略了两个任务之间的关联。而后期采取的联合模型都存在着一个严重问题&#xff1a;训练时&#xff0c;真实值作为上下文传入训练&#xff1b;推理时&#xff0c;模型自身生成的值作为上下文传入&a…

DolphinScheduler 3.3.0版本更新一览

Apache DolphinScheduler即将迎来3.3.0版本的发布&#xff0c;届时将有一系列重要的更新和改进。在近期的社区5月份用户线上分享会上&#xff0c;项目PMC 阮文俊为大家介绍了3.3.0版本将带来的主要更新和改进&#xff0c;并为大家指出了如何参与社区的方式。 什么是DolphinSch…

企业内网终端监控管理软件有哪些?推荐4款企业终端监控管理软件

企业内网终端监控管理软件是一种专为企业内部网络设计的安全与管理工具&#xff0c;旨在帮助企业管理、监控和保护其内部网络中的各种终端设备&#xff0c;如个人电脑、笔记本、移动设备等。 这类软件的主要功能包括但不限于以下几个方面&#xff1a; 1&#xff0c;实时监控&a…

Java面试八股之start()和run()的区别

start()和run()的区别 在Java中&#xff0c;run()方法和start()方法是与线程操作紧密相关的&#xff0c;两者之间存在本质的区别&#xff1a; start()是Thread类的一个实例方法&#xff0c;它的主要作用是启动一个新的线程。当调用线程对象的start()方法时&#xff0c;Java虚…

手搓顺序表(C语言)

目录 SeqList.h SeqList.c 头插尾插复用任意位置插入 头删尾删复用任意位置删除 SLtest.c 测试示例 顺序表优劣分析 SeqList.h //SeqList.h#pragma once#include <stdio.h> #include <assert.h> #include <stdlib.h> #define IN_CY 3typedef int S…

Android环境下Mesa初始化流程重学习之eglInitialize

Mesa初始化流程重学习之eglInitialize 引言 说来也惭愧&#xff0c;Mesa搞了这么久了&#xff0c;每次都想深入下&#xff0c;可是每次都是浅尝辄止了。这次趁着有了一定的闲暇时间并且有了调试景嘉微显卡的机会&#xff0c;还是想重新学习下&#xff0c;深入研究下&#xff0…

MongoDB分片集群容灾方案

MongoDB分片集群容灾方案 1. 集群同步工具介绍1.1 第三方数据同步工具mongoshake1.2 官方同步工具mongosync 2. 工具对比2.1 数据一致性2.2 稳定性和可靠性2.3 维护成本 3. 总结 1. 集群同步工具介绍 最近客户咨询MongoDB分片集群市面上主流的容灾方案&#xff0c;所以抽空整理…

Node.js —— Express中服务器的创建、托管静态资源、nodemon

目录 Express的安装 创建基本的 Web 服务器 监听GET请求 监听POST请求 把内容响应给客户端 ​编辑获取 URL 中携带的查询参数 ​编辑获取 URL 中的动态参数 ​编辑托管静态资源 express.static() 托管多个静态资源目录 挂载路径前缀 nodemon: 为什么要使用 nodemon 安…

如何让UE4.26使用VS2022【Windows,源码下载】

使用UE5一直用的是VS2022&#xff0c;都是因为团队需要&#xff0c;只能用UE4&#xff0c;而我电脑中拥有的UE4的版本是UE4.26以及VS2022&#xff0c;我不可能去下载VS2019来为这么一个项目&#xff0c;所以就研究了一下是哪里阻止了UE4.26不让我使用VS2022. 首先下载UE4.26源码…

守护景区安全:探讨景区视频监控方案的搭建及必要性

据新闻报道&#xff0c;5月25日&#xff0c;安徽黄山景区内发生雷击&#xff0c;闪电击中飞来石景点的护栏&#xff0c;多人被碎石砸中受伤。景区工作人员表示&#xff0c;飞来石附近本就属于雷区&#xff0c;当天曾发过两次雷电预警。 随着旅游业的繁荣发展&#xff0c;越来越…

掌握Adobe XD:为自学者准备的软件学习秘籍

相信了解一些设计软件的朋友都听说过这个软件&#xff0c;Adobe XD软件是一款功能强大的原型创建工具。随着Adobe XD软件越来越受到用户的青睐&#xff0c;它几乎涵盖了所有大中小企业和企业的设计&#xff0c;可以说是设计公司最常用的软件之一。Adobe XD软件可以在很多方面满…

Android制作.9图

需求背景&#xff1a;android 启动图变形 开发语言&#xff1a;uni-app&#xff0c;uni-app官网 俗语曰&#xff1a;授人以鱼不如授人以渔 原创地址&#xff1a;Android制作.9图 语雀 一.工具 使用android studio&#xff0c;因为android studio已经集成.9.png制作工具&a…

godot4.2 + GDextension c++在 vs code 中断点调试配置

游戏开发中如果做不到自己编写的代码做断点调试&#xff0c;无不是瞎子摸象&#xff0c;特别是C这么底层的语言。这2天开始在VS studio中折腾&#xff0c;一直折腾不出结果&#xff0c;几次想要放弃GODOT。最终今天在VS code中搞定了这断点调试C代码。 在上一篇文章我已经做好了…

axios和ts的简单使用

按照官网的使用案例简单记下笔记 1&#xff1a;安装 npm install axios 2&#xff1a;案例 一个简单的config配置信息 // 发起一个post请求 axios({method: post,url: /user/12345,data: {firstName: Fred,lastName: Flintstone} }); case // 在 node.js 用GET请求获取…