前言:本文将介绍如何基于ProxylessNAS搜索semantic segmentation模型,最终搜索获得的模型结构可在CPU上达到36 fps的测试结果,展现自动网络搜索(NAS)在语义分割上的应用。html
随着自动网络搜索(Neural Architecture Search)技术的问世,深度学习已慢慢发展到自动化设计网络结构以及超参数配置的阶段。尤为在AI落地的背景下,许多模型须要部署在移动端设备。依据不一样设备(GPU, CPU,芯片等),不一样的模型需求(latency, 模型大小,FLOPs),使用NAS自动搜索最佳网络结构将会是一个颇有潜力的方向。上一篇介绍了NAS的基本框架和入门必读DARTS [1],以及在semantic segmentation领域的应用。 距离如今才不过几个月,NAS论文数量明显增加:在理论研究方面,search strategy,evaluation performance的方法看似趋于稳定,不得不提到最近FAIR团队的RegNet [2]探讨了搜索空间的设计,经过大量实验把常见的设计模型的理论一一验证,咱们能够根据它的结论缩小搜索空间从而提升搜索效率;在应用方面以仍是object detection为主,也有segmentation, reID, GAN等领域。算法
NAS算是一项新技术,可是语义分割semantic segmentation倒是老生常谈。自FCN的问世起,SegNet, UNet这种简单粗暴的encoder-decoder结构在多种图像上都能达到能够接受的结果,deeplab系列以后更是在开源数据集达到巅峰。从学术角度看semantic segmentation彷佛已达到瓶颈,因而researcher们纷纷转向小样本,semi-supervised,domain adaption, cloud point等方向另辟蹊径。可是semantic segmentation落地却很是困难。在实际落地场景中,使用常见的backbone (resnet或yolo系列) 就可以完成各类object detection任务,可是在segmentation上效果却很差:segmentfault
Semantic segmentation落地必需要平衡模型的准确度和速度,而设计这样的网络结构又十分困难。尝试了BiSeNet [3],ShuffleNetv2 [4],MobileNetv3 [5]等一系列小模型,可是准确度和速度都没达到要求。正所谓万丈高楼平地起,成功只能靠本身,最终仍是要寄但愿于NAS自动搜索出知足条件的模型。上篇介绍的NAS用在语义分割还在探索阶段,在GPU上运行而且尝试减少FLOPs或Params。可是FLOPs或者参数量与模型推理速度并非正相关,只减小参数量不能知足实时推理的要求。后来的FasterSeg [6]看似速度惊人,其实也用了TensorRT来加速。本文将尝试在CPU上完成实时的人形分割的任务,选择ProxylessNAS做为baseline来搜索模型结构。实验结果证实了ProxylessNAS [7]仍是经得起考验的,业界良心。网络
选择ProxylessNAS [7]的缘由不只仅是它出自名门,代码开源,在Cifar10和ImageNet数据集的准确度能从一众NAS模型中脱颖而出, 并且它也是比较早的考虑到了模型性能的work(如速度,模型大小,参数量)。 除此以外,与DARTS [1]系列搜索的DAG cell不一样,ProxylessNAS [7]的主干网络采用简单的链状结构。这种链状结构(chained-structure)比DAG cell有明显的速度优点,由于它的算子之间的链接方式比较简单。app
1.1 Super-net setting框架
咱们仍是用NAS的基本框架来解析ProxylessNAS [7]。less
Figure 1: NAS frameworkdom
1.2 Super-net trainingide
Super-net的参数包含两部分:operation自己的参数和每一个operation的权重(在Figure2中记为{alpha,beta,sigma … })。将训练数据分红两部分,一部分用来训练super-net里面operations的weight,另外一部分用来更新ops的权重。性能
Figure 2 illustrates the architecture of the super-net: the chained-structure searchable backbone (left) and each layer of the searchable backbone (right).
Figure 2所表达的ProxylessNAS的流程,其实就是一边训练operation参数,一边更新operation的权重alpha,最后用Softmax选择每一层中拥有最大probability的operation便可。读过paper以后确实发现有许多值得借鉴之处,可是一样也有一些疑问 (c.f. Table 1)。
Table 1 discusses the advantages and remaining issues of ProxylessNAS
尽管对ProxylessNAS还有不少没有解决的问题,奈何单卡搜索训练省时省力瑕不掩瑜。借助Intel的openvino推理框架,本文尝试用ProxylessNAS搜索可运行在CPU(x86)上的real-time semantic segmentation模型作人形分割,下面会详细介绍对算法的改进和实验结果。
2.1 Super-net setting
Figure 3 illustrates the macro-architecture of our super-net (top) and the searchable backbone (bottom)
2.2 Improvement from ProxylessNAS
2.3 Experiments
Experiment setting:
https://software.intel.com/content/www/us/en/develop/tools/openvino-toolkit.html
Experimental results:
在同一网络结构下,咱们用MobileNetv3 [5]做为backbone进行对比,对比结果见Table 2。
Table 2 illustrates the experimental results
从实验数据来看,MobileNetv3 [5]的参数量和FLOPs都比咱们搜索出来的小一倍,可是在K80上的推理速度很相近,准确度mIoU差异较大。若是综合考量准确度和速度的话,咱们用ProxylessNAS [7]搜索出来的backbone要明显优于MobileNetv3 [5]的backbone。 Figure 4的实验结果能够看出当feature复杂一些的时候,MobileNetv3 [5]的结果要差不少
Figure 4 compares the segmentation results of our searched network and MobileNetv3
将模型转化成openvino可支持模式部署在CPU (Intel Core i7-8700)上,运行速度在27ms每帧左右(FPS=36),结果如Figure 5。
Figure 5 shows the segmentation results in real application scenario
是时候展现一下搜索出来的backbone了,长这样~ (c.f. Figure 6)
Figure 6 illustrates the searched backbone structure
经过实验咱们看到ProxylessNAS搜索策略能够从classification迁移到segmentation,在速度相仿的状况下,搜索出来的网络要比本来MobileNetv3 [5]准确度提升不少。可是只限于当前的场景,不能说人工设计出来的模型就很差或必定会被取代(虽然MobileNetv3也是NAS搜出来的)。在特定场景和有特定需求的时候,用NAS设计网络结构确实比人工设计加上大量调参实验要更高效,在AI落地方面更有发展前景。本文只是初探ProxylessNAS,后续还会有如下几个方面的探索。
下一篇我会介绍一下关于背景抠图的实战经验,敬请期待。
Figure 7 shows the demo of background matting
References
[1] Liu, Hanxiao, Karen Simonyan, and Yiming Yang. "Darts: Differentiable architecture search." ICLR (2019).
[2] Radosavovic, Ilija, et al. "Designing Network Design Spaces." arXiv preprint arXiv:2003.13678 (2020).
[3] Yu, Changqian, et al. "Bisenet: Bilateral segmentation network for real-time semantic segmentation." Proceedings of the European conference on computer vision (ECCV). 2018.
[4] Zhang, Xiangyu, et al. "Shufflenet: An extremely efficient convolutional neural network for mobile devices." Proceedings of the IEEE conference on computer vision and pattern recognition (CVPR). 2018.
[5] Howard, Andrew, et al. "Searching for mobilenetv3." Proceedings of the IEEE International Conference on Computer Vision (ICCV). 2019.
[6] Chen, Wuyang, et al. "FasterSeg: Searching for Faster Real-time Semantic Segmentation." ICLR (2020).
[7] Cai, Han, Ligeng Zhu, and Song Han. "Proxylessnas: Direct neural architecture search on target task and hardware." ICLR (2019).
[8] Sandler, Mark, et al. "Mobilenetv2: Inverted residuals and linear bottlenecks." Proceedings of the IEEE conference on computer vision and pattern recognition (CVPR). 2018.
[9] Chen, Liang-Chieh, et al. "Encoder-decoder with atrous separable convolution for semantic image segmentation." Proceedings of the European conference on computer vision (ECCV). 2018.