4lqedz 发表于 2024-10-2 23:31:47

百度智能边缘集成EasyEdge,快速实现边缘AI模型推断

<span style="color: black;">在人工智能<span style="color: black;">行业</span>,深度学习<span style="color: black;">表率</span>了当下较为火热的<span style="color: black;">设备</span>学习技术,深受学术界与产业界<span style="color: black;">注重</span>。</span><span style="color: black;"><span style="color: black;">因为</span>深度学习模型的高准确率与高<span style="color: black;">靠谱</span>性,深度学习技术已在计算机视觉、语音识别与自然语言处理<span style="color: black;">行业</span>取得了广泛的成功应用。</span><span style="color: black;">深度学习模型<span style="color: black;">亦</span>如雨后春笋般涌现,并且越来越多的模型被开源。</span><span style="color: black;">在最<span style="color: black;">初期</span>,受限于深度学习模型<span style="color: black;">针对</span>算力的<span style="color: black;">需要</span>,模型大<span style="color: black;">大都是</span>”云端训练、云端推理“。</span><span style="color: black;">然而”云端推理“模式需要将<span style="color: black;">海量</span>的数据(如图像和视频数据)<span style="color: black;">经过</span>高延迟、带宽波动的广域网从边缘端传输至云端。</span><span style="color: black;">在离线<span style="color: black;">或</span>低延时<span style="color: black;">需求</span>的场景下,<span style="color: black;">没法</span>满足<span style="color: black;">实质</span><span style="color: black;">需要</span>。</span><strong style="color: blue;"><span style="color: black;">随着AI芯片的兴起,边缘算力的逐步<span style="color: black;">加强</span>,将模型推理下放到边缘侧<span style="color: black;">已然</span><span style="color: black;">作为</span>当前的一大主流趋势。</span></strong><span style="color: black;">虽然算力支持在边缘进行模型推断,<span style="color: black;">然则</span>模型的<span style="color: black;">运用</span><span style="color: black;">繁杂</span>度与门槛依然很高,为了调用模型需要编写许多代码,为了适配端侧<span style="color: black;">区别</span>的芯片与操作系统,还需要对原始模型<span style="color: black;">持续</span>进行修改、优化、调参等操作。</span><strong style="color: blue;"><span style="color: black;">为此,<span style="color: black;">非常多</span><span style="color: black;">科研</span>人员都在<span style="color: black;">科研</span><span style="color: black;">怎样</span>降低模型的<span style="color: black;">运用</span>门槛, 让模型的应用者专注于业务,将模型做成服务<span style="color: black;">同样</span>按需调用,实现边缘侧的model as a service。</span></strong><span style="color: black;">百度智能边缘+EasyEdge集成就很好的<span style="color: black;">处理</span>了这个问题。</span>0<span style="color: black;">1</span>EasyEdge是什么?<span style="color: black;">EasyEdge是百度基于Paddle Mobile<span style="color: black;">开发</span>的端计算模型生成平台,能够将原始深度学习模型快速生成适配于边缘节点和智能终端的端侧模型。</span><strong style="color: blue;"><span style="color: black;">EasyEdge支持模型信息如下:</span></strong><strong style="color: blue;"><span style="color: black;">支持的模型框架<span style="color: black;">包含</span></span></strong><strong style="color: blue;"><span style="color: black;">:</span></strong><span style="color: black;">Caffe (ssd)、PyTorch (0.4.0) 、TensorFlow (1.13)、PaddlePaddle (1.4.1)</span><strong style="color: blue;"><span style="color: black;">支持的模型网络<span style="color: black;">包含</span></span></strong><span style="color: black;">:VGG16、InceptionV3/V4、MobilenetV1、MobilenetV1-SSD、RestnetV1等13种</span><strong style="color: blue;"><span style="color: black;">支持的AI加速芯片<span style="color: black;">包含</span>:</span></strong><span style="color: black;">通用ARM芯片、通用x86芯片、英伟达GPU、高通Snapdragon GPU/DSP、英特尔Movidius VPU、华为HiSilicon NPU、苹果A-Bionic</span>0<span style="color: black;">2</span>BIE是什么?<span style="color: black;">百度智能边缘(Baidu IntelliEdge)旨在将云计算能力拓展至用户现场,<span style="color: black;">供给</span><span style="color: black;">能够</span>临时离线、低延时的计算服务,<span style="color: black;">包含</span>设备接入、数据处理、数据上报、函数计算、AI 推断等功能。</span><span style="color: black;">BIE整体<span style="color: black;">包含</span>边缘本地运行包和云端管理套件两部分:</span><strong style="color: blue;"><span style="color: black;">本地运行包:</span></strong><span style="color: black;">本地运行包<span style="color: black;">包括</span>百度开放边缘框架BAETYL,以及基于BAETYL框架开放的边缘应用,实现将云计算能力延伸至边缘,<span style="color: black;">供给</span>离线自治、低延时的计算服务。</span><strong style="color: blue;"><span style="color: black;">云端管理套件</span></strong><strong style="color: blue;"><span style="color: black;">:</span></strong><span style="color: black;"><span style="color: black;">重点</span>负责边缘设备节点的管理,<span style="color: black;">包括</span>设备节点的监控、注册管理、应用的编排与升级等功能。除此之外,云端套件还负责与百度智能云的其他服务进行集成对接,<span style="color: black;">包含</span>函数计算CFC,流式计算BSC,端侧模型生成框架EasyEdge等。实现”云管理、边运行、边云一体“的整体<span style="color: black;">处理</span><span style="color: black;">方法</span>。</span>0<span style="color: black;">3</span>BIE<span style="color: black;">为何</span>要与EasyEdge集成?<span style="color: black;">BIE与EasyEdge集成,是百度智能云践行“ABC Anywhere”战略的重要一步。</span><span style="color: black;">EasyEdge为BIE<span style="color: black;">供给</span>了边缘模型适配与模型加速的能力,</span><span style="color: black;">让众多的模型<span style="color: black;">作为</span><span style="color: black;">能够</span>运行在</span><span style="color: black;">BIE</span><span style="color: black;">边缘框架上的一种服务,实现</span><span style="color: black;">Model as a Service</span><span style="color: black;">。</span><strong style="color: blue;"><span style="color: black;"><span style="color: black;">经过</span>BIE与EasyEdge的集成,为用户<span style="color: black;">供给</span>了“模型适配——&gt;模型下发——&gt;模型运行”的全链路服务。</span></strong><span style="color: black;"><strong style="color: blue;">尝试此功能</strong></span><span style="color: black;"><span style="color: black;">倘若</span>要尝试此项功能,<span style="color: black;">能够</span>登录智能云<span style="color: black;">掌控</span>台,<span style="color: black;">详细</span>操作指南参考:</span><span style="color: black;">https://cloud.baidu.com/doc/BIE/s/Tk2n4o50o</span>0<span style="color: black;">4</span>BIE与EasyEdge集成的效果<span style="color: black;">在MobileNet-SSD-Caffe物体检测模型以服务形式运行在边缘节点设备上以后,<span style="color: black;">咱们</span><span style="color: black;">能够</span><span style="color: black;">经过</span>两种方式进行检验,一种是浏览器校验,还有一种是API校验。</span><span style="color: black;"><strong style="color: blue;"><span style="color: black;">浏览器校验</span></strong></span><span style="color: black;"><span style="color: black;">经过</span>浏览器打开物体检测服务的<span style="color: black;">掌控</span>台,<span style="color: black;">拜访</span><span style="color: black;">位置</span>为:http://[边缘核心设备IP<span style="color: black;">位置</span>]:8088/&nbsp;。<span style="color: black;">倘若</span>能够看到如下界面,则<span style="color: black;">暗示</span>服务正常运行。</span><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggQicOxI31C25LcgqGyF6uqD5UmftTn7ZAbPwKuTPN43MKvaQveN1nlzQ/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggWejRq4VhZ5JeTg3XdmrEfyZPFDaibczNy7vJxrlg9yYm3ibhfLEib2GYw/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">接下来<span style="color: black;">能够</span>上传样例<span style="color: black;">照片</span>校验模型效果,以下为几个样例结果:</span><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggQicOxI31C25LcgqGyF6uqD5UmftTn7ZAbPwKuTPN43MKvaQveN1nlzQ/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9gg8dn7sW5SVZhzoxPKfjowRrDia8sU4VOAMewtREf7Q28e5bdURwu4WNA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggLb9JWsBI9iaW69GQYIuaF5BVbQd4dOFqY8aRf56zuiaxCl2KuVLg7icXA/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggxcHUkq8M2e5lCmXaPfpIfGbJaRWiaVxEFM4p9xCHqFnpuIhQlWm9JoQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><img src="https://mmbiz.qpic.cn/mmbiz_png/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggZvIrfJlvHEAFOdZ4ZiawHcBmkUU5HGjyyJmABHFBDteZWuJEs9Zu9PQ/640?wx_fmt=png&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;"><strong style="color: blue;"><span style="color: black;">API校验</span></strong></span><span style="color: black;">MobileNet-SSD-Caffe 本身<span style="color: black;">做为</span>一个容器应用运行在边缘核心<span style="color: black;">其中</span>,它<span style="color: black;">同期</span>对外<span style="color: black;">供给</span>API<span style="color: black;">拜访</span>接口,支持被其他应用调用,并返回物体检测结果。</span><span style="color: black;">下面<span style="color: black;">经过</span>python代码调用接口进行示例说明:</span><strong style="color: blue;"><span style="color: black;"><span style="color: black;">·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>拷贝下面的python代码<span style="color: black;">保留</span>至本地,命名为test_MobileNet_SSD_api.py</span></strong><span style="color: black;">import requests</span><span style="color: black;"><span style="color: black;">with</span> <span style="color: black;">open</span>(<span style="color: black;">./1.jpg</span>, <span style="color: black;">rb</span>) <span style="color: black;">as</span> f:</span><span style="color: black;"> img = f.read()</span><span style="color: black;"><span style="color: black;"># params is GET params, data is POST Body</span></span><span style="color: black;"><span style="color: black;">result</span> = requests.post(<span style="color: black;">http://[边缘核心设备IP<span style="color: black;">位置</span>]:8088/</span>, params={<span style="color: black;">threshold</span>: <span style="color: black;">0.1</span>},<span style="color: black;">data</span>=img).json()</span><span style="color: black;">print&nbsp;<span style="color: black;">result</span></span><strong style="color: blue;"><span style="color: black;"><span style="color: black;"><span style="color: black;">·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></span>下载</span><span style="color: black;"><span style="color: black;">照片</span> 1.jpg</span></strong><span style="color: black;"><span style="color: black;">保留</span>至与test_MobileNet_SSD_api.py同目录下。</span><img src="https://mmbiz.qpic.cn/mmbiz_jpg/6nWVkbiaAIRKzibKSzGUEuTusrR4SLQ9ggAG1NQpCcTcmXQJjibQlYs7BmtUev1S68TBHLxlkzuibGx1sz9stVtA2w/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;"><span style="color: black;">照片</span>1<strong style="color: blue;"><span style="color: black;"><span style="color: black;">·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>执行test_MobileNet_SSD_api.py</span></strong><span style="color: black;"><span style="color: black;">python</span> <span style="color: black;">test_MobileNet_SSD_api</span><span style="color: black;">.py</span></span><span style="color: black;"><strong style="color: blue;">·&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 查看接口返回结果为如下JSON</strong></span><span style="color: black;">{</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"error_code"</span>:&nbsp;<span style="color: black;">0</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"cost_ms"</span>:&nbsp;<span style="color: black;">179</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"results"</span>:&nbsp;&nbsp;&nbsp;[</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"index"</span>:&nbsp;<span style="color: black;">8</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"confidence"</span>:&nbsp;<span style="color: black;">0.9999642372131348</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"y2"</span>:&nbsp;<span style="color: black;">0.9531263113021851</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"label"</span>:&nbsp;<span style="color: black;">"cat"</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"y1"</span>:&nbsp;<span style="color: black;">0.0014175414107739925</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"x2"</span>:&nbsp;<span style="color: black;">0.9970248937606812</span>,</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span style="color: black;">"x1"</span>:&nbsp;<span style="color: black;">0.0014758188044652343</span></span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}</span><span style="color: black;">&nbsp;&nbsp;&nbsp;&nbsp;]</span><span style="color: black;">}</span><span style="color: black;"><span style="color: black;">经过</span><span style="color: black;">以上</span>返回结果,<span style="color: black;">咱们</span><span style="color: black;">能够</span><span style="color: black;">晓得</span>该物体检测模型检测到的物体是cat,可信度为0.999964≈1。</span><span style="color: black;">点击</span><span style="color: black;"><strong style="color: blue;">阅读原文</strong></span><span style="color: black;">,查看<span style="color: black;">仔细</span>的<span style="color: black;">运用</span>教程。</span><img src="https://mmbiz.qpic.cn/mmbiz_gif/6nWVkbiaAIRKy7DsYDBIKE5Z5TvG7pglsBqwGl1J5L8ItjglxPdo9b59KGQG0rLLL7SdH8TRbv7cO2NpfYWdP6g/640?wx_fmt=gif&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1" style="width: 50%; margin-bottom: 20px;"><strong style="color: blue;"><span style="color: black;">本文作者徐伟,百度智能云高级<span style="color: black;">制品</span>经理。</span></strong><img src="https://mmbiz.qpic.cn/mmbiz_jpg/6nWVkbiaAIRKwsBerMuAm4759GPP9CGbpibTriaA1tA4Kd73x3YtEGTvAPlu5Ra4icxcszm49yfia55m5SqA1Wpv9yA/640?wx_fmt=jpeg&amp;tp=webp&amp;wxfrom=5&amp;wx_lazy=1&amp;wx_co=1" style="width: 50%; margin-bottom: 20px;">点击<span style="color: black;">这儿</span>阅读原文



qzmjef 发表于 2024-10-7 13:10:45

感谢楼主分享,祝愿外链论坛越办越好!

j8typz 发表于 2024-10-28 00:51:33

说得好啊!我在外链论坛打滚这么多年,所谓阅人无数,就算没有见过猪走路,也总明白猪肉是啥味道的。

b1gc8v 发表于 6 天前

你的见解真是独到,让我受益匪浅。
页: [1]
查看完整版本: 百度智能边缘集成EasyEdge,快速实现边缘AI模型推断