不止轻量,高性能图像处理库 ppl.cv 来袭

Posted OpenPPL

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了不止轻量,高性能图像处理库 ppl.cv 来袭相关的知识,希望对你有一定的参考价值。

x86,aarch64 和 CUDA 三个平台,并计划加入对 RISC-V 平台的支持,未来也将根据社区反馈支持更多的架构后端。

  • ppl.cv x86 架构为广泛支持各种机器,大多数算子会采用 sse 指令集进行优化,少数算子会在sse 指令集性能仍不理想时采用 AVX 指令集甚至 FMA 指令集进行优化,可以覆盖绝大多数应用场景。

  • ppl.cv aarch64 架构为 ARM Server而生,我们积极拥抱 ARM 全面向 64 位转换。当然,ppl.cv在移动端aarch64上的性能也不容小觑哦。

  • ppl.cv CUDA 支持计算能力 3.5 以上英伟达 GPU,包括Kepler/Maxwell/Pascal/Volta/Turing/Ampere 等架构的芯片,CUDA 支持英伟达发布的所有版本,建议使用 CUDA 7.0 以上较新版本。

  •  

    ppl.cv 的优势

    一、功能与接口对齐 OpenCV

    OpenCV 是计算机视觉领域里,诸多图像处理库中算子实现算法数学原理严谨、用户广泛的典范,ppl.cv 在功能和接口上对齐 OpenCV。

    ppl.cv 各平台的各算子均实现 OpenCV 中同接口函数的全部或部分功能,而且两者结果除平台硬件差异导致的精度差异外皆对齐。接口参数中,大部分采用与 OpenCV 接口一致的形参。涉及存储的地方,ppl.cv 与常规算法一样采用标准的存储,即存储指针,外加数组高、宽、每行数据占用大小等参数表征二维数组,未如 cv::Mat 进行封装。

    ppl.cv 以此降低用户的学习成本,提高 ppl.cv 的使用效率。


    二、函数耦合度低

    考虑到 OpenCV 的庞大深度学习应用需求和移植 OpenCV 算子的复杂度,ppl.cv 设计时便规划降低算子之间的耦合度,降低算子对其他定义的依赖。

    除了对部分各平台共享类型定义的依赖,大部分算子没有或只有较少依赖,以便于移植和个性化定制。ppl.cv 用户既可以完整地使用 ppl.cv 库,也可以只采用某个硬件平台对应的 ppl.cv 库,还可以按需裁剪只采用某个硬件平台对应 ppl.cv 库的一个或若干算子,非常适合做个性化定制,避免被 cv 库的体量束缚应用开发。


    三、极致性能

    最后也是最重要的一点,OpenPPL 的一贯要求就是追求极致性能,ppl.cv 在各个架构下绝大部分都比 OpenCV 要快。

    ppl.cv 针对特定硬件平台,从存储访问和计算两方面做了深度优化。通过理论分析和实验测试发现大部分算子为 memory bound 类型的函数,少量算子为 compute bound 类型的函数。

    对于存储访问,ppl.cv 通过采用满足的较小数据结构、减少存储分配和释放、地址对齐和 cache 友好的存储访问方式提升存储访问性能。对于计算,ppl.cv 通过定点量化、压缩运算和在满足精度的前提下采用 float 运算替换 double 运算等优化手段。

    与 OpenCV 相应实现相比,获得了较好的加速比。

    ppl.cv,又快又轻

    一、x86 benchmark

    我们取了几个经典算子在一些经典分辨率的图像尺寸下与 OpenCV 的性能数据对比,图像一般都是以 uint8 的数据类型存储,所以我们 benchmark 选择 uint8 类型的数据展示,当然 ppl.cv 对 float 类型的图像也做了深度优化。Benchmark 均采用 intel Xeon 10980 处理器单核单线程测试。

    △ 颜色空间转换中的 NV12 图像转为 BGR 图像的算子

    △ 图像处理形态学类型中膨胀算子经典的 3x3kernel 的性能数据对比

     

    二、CUDA benchmark

    OpenCV 中部分算子有 x86/CUDA 两种实现,部分只有 x86 实现,ppl.cv.cuda 以OpenCV x86/CUDA 已有实现中最快的版本作为性能测试对比对象。

    对于某一个算子,性能测试根据输入参数类型和取值设计具有较广覆盖面的参数组合进行测试,计算与 OpenCV 实现相对的加速比并排序,参考统计学中的盒图概念,以最小加速比、中位数加速比和最大加速比作为函数性能对比指标展示 ppl.cv.cuda 的性能。

    ppl.cv.cuda 共开源 174 APIs。其中,156 APIs 取得 1~59 倍不等的加速比,14 APIs 仅最小加速比小于 1,4 APIs 最小和中位数加速比小于 1,其中 norm/integral 算子因为算法串行特性慢于 OpenCV x86(但快于 OpenCV CUDA 实现)。

    下图为以 BitwiseAnd() 为例,ppl::cv::cuda::BitwiseAnd() 与 cv::cuda::bitwise_and() 不同参数组合下的性能对比(Time 列数值为算子平均执行时间):

     

    三、aarch64 benchmark

    ppl.cv aarch64 架构初期开源了部分与 OpenMMLab 模型前处理所必需的算子,后续我们会继续开源更多的 cv 算子,达到接口和 x86,CUDA 等架构完全对齐。benchmark 均采用鲲鹏 920 处理器单核单线程测试。

    △ 颜色空间转换中的彩色图像转为灰度图像的算子

    △ 图像处理形态学类型中腐蚀算子经典的 3x3kernel 的性能数据对比


    ⭐️ 欢迎 star 

    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝

    The world’s biggest e-shopping holiday is less than 24 hours away: Alibaba’s Singles’ Day (“Double 11”).


    But already the complaints are in from Chinese shoppers that this year’s discount guidelines are more like a gaokao math problem than a sale. For example:



    If a coat costs 1,348 RMB and customers get a Taobao rebate of 30 RMB for every 600 RMB spent, but Taobao members who  pre-order between October 19 and October 26 get an additional 20 percent discount (or 10 percent between October 27 and November 2), how much do you actually save? (ifeng.com)

     

    But shopping rules aren’t the only confusing thing: Alibaba has a wide variety of platforms catering to different customers and transactions. Many have similar layouts and names, and it’s possible to search on multiple platforms at once. To the company, it probably doesn’t matter where you end up in the Ali-world as long as you buy, buy, buy—but for the buyer, here’s a guide to the company’s main e-commerce platforms, all of which can be logged onto from a single, central account on Taobao.com.

     

     

    Alibaba (alibaba.com, 1688.com)



    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    The website that started it all: Founded by Jack Ma (and 18 friends) in Hangzhou in 1999, Alibaba is a business-to-business trading platform connecting Chinese small and medium-sized businesses with importers around the world. It’s now the world’s largest B2B trading website, and 1688.com is the version for transaction between domestic Chinese businesses. Regular customers—those not wanting to buy minimum orders of 1,000 winter coats or glass jars—are unlikely to visit on this “Singles’ Day.”

     

    Taobao (taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    They’ll likely instead spend all their time here: Founded in 2003, Taobao is a consumer-to-consumer trading platform that now has 488 million annual active users. It started taking off in a big way in the mid-to-late-2000s, due to low requirements to register to sell (an ID card and minimal technical know-how) that made the platform especially popular for independent merchants and rural communities. Singles’ Day deals include discounts from individual vendors and hongbao from the site itself.

     


    Tmall (tmall.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    Originally known as Taobao Mall, Taobao’s B2C trading platform, Tmall spun off into a separate company under the Alibaba Group in 2011; its Chinese name, Tianmao, is “Sky Cat.” Tmall is where most of the Single’s Day action is set to happen, including the biggest merchant discounts and daily hongbao draws for the past month or so.

     


    Xianyu (2.taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    Xianyu is a platform for trading second-hand goods, but most of its functions are no longer available except through the mobile app. Apart from second-hand items, Xianyu’s apartment listings (mobile only) are popular. The name means “Idle Fish” and comes from the Chinese word xiánzhì (闲置), meaning to set aside items one no longer uses. Taobao users can create an automatic Xianyu listing for items they just bought and already don’t want anymore by clicking a button under to the item in their order history; listings created this way will include a link to the original Taobao page for the item, if still available.

     


    Aliexpress (aliexpress.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    A retail website for Chinese vendors and international customers, it’s basically an foreign-facing version of Taobao with a less user-friendly interface and slower shipping. Some functions, such as product reviews and ability to instant-message the vendor, are the same as Taobao.

     


    Gmall (g.taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    On the other side of the coin, Gmall is Taobao’s brand for goods purchased from abroad and resold to Chinese consumers through Taobao, generally listed by daigou. Customers can search for the item on the Gmall site or on the main Taobao site, where Gmall listings will be displayed in the search results with a small Gmall logo at the bottom.

     


    Fliggy (alitrip.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    Continuing the animal-themed naming, Fliggy is called Feizhu (“Flying Piggy”) in Chinese and is a travel-booking and planning platform with all the standard functions—booking hotels, plane and train tickets, package tours, rental cars, and tickets to scenic destinations, domestic and international. Rebranded from its old name, Alitrip, in 2016 (though the URL is unchanged), Fliggy appears to be not very well known abroad and has stiff competition within China from the likes of Ctrip and Qunar. Since it is part of the Ali-ecosystem, tour operators can get their products and deals to show up as a search result on Taobao for users who type in the keywords.

     


    Juhuasuan (ju.taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    Another spin-off of Taobao, Juhuasuan is a group-buying platform far better known for offering different “flash sales” every day: certain items are discounted for a limited time and customers are urged to snap them up quickly. It’s most useful for those wanting to buy name-brand products.

     

     

    Etao (etao.taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    A comparison-shopping website that allows gives users search results not only from Taobao and Tmall, but other e-commerce sites around the web such as JD.com. Like Juhuasuan, there are flash sales and daily discounts, usually also for big brands.

     


    Xianyu Auction (paimai.taobao.com)


    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝


    Ever wish that Taobao was more like Ebay, where you can watch a clock counting down with bleary eyes as you wake up at 3 am to make sure that another user hasn’t outbid you in the auction? Well, a small percentage of listings on the main Taobao site are for auction, but the Ali-family also has Xianyu Paimai, a site dedicated to auctions. Paimai’s products are all on the higher end—jewelry, luxury clothes and watches, art and antiques, and houses and cars—and listed by professional auction houses or dealers.

     


    Judicial Auction (sf.taobao.com)



    This is the good stuff: Assets seized in lawsuits are auctioned off by courts around the country—1,900 courts in 30 provinces as of February. These  items include cars, homes, real-estate developments, and land. The site was founded in 2012, and officials have touted e-commerce as a means to make judicial auctions less restricted by geography and more transparent.


     

    Cover photo from Beishan “Taobao village” in Jinyun county, Zhejiang, by Hatty Liu



    The World of Chinese

    magazine



    How to follow us


    Long press the QR code


    How to subscribe


    Tap BUY on our Wechat menu  


    Click to read more articles

    ↓↓↓↓↓↓↓↓

    以上是关于不止轻量,高性能图像处理库 ppl.cv 来袭的主要内容,如果未能解决你的问题,请参考以下文章

    A Quick Guide to Alibaba “双十一”来袭!阿里巴巴的业务不止是天猫淘宝

    苹果M1X来袭,性能翻倍,ARM处理器性能再创新高,Intel瑟瑟发抖

    性能测试:这台16万的机甲兽,百公里加速比2.0T途观还快

    轻量且高性能的 React 状态管理库 Jotai

    限时领奖消息队列MNS训练营重磅来袭,边学习充电,边领充电宝~

    限时领奖消息队列MNS训练营重磅来袭,边学习充电,边领充电宝~