From 246042be6a1b4ebee0058c2a83584101683c1479 Mon Sep 17 00:00:00 2001 From: zheng-wengang1 Date: Thu, 9 Dec 2021 11:57:36 +0800 Subject: [PATCH 1/2] fix img bugs --- ...43\345\206\263\346\241\210\344\276\213.md" | 28 +++++++++++++++---- 1 file changed, 23 insertions(+), 5 deletions(-) diff --git "a/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" "b/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" index 8dc7288..a509495 100644 --- "a/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" +++ "b/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" @@ -6,11 +6,11 @@ [HigherNet](https://github.com/HRNet/HigherHRNet-Human-Pose-Estimation)出自CVPR2020,为经典的人体检测网络模型,基本算法框架见下图。HigherNet在推理过程中,输入图片的shape不是单一的固定输入,但是不是完全的动态,而是按照64(stride)倍数分为若干挡位,适合采用分档模型的方案。对应的代码可见:[modelzoo](https://gitee.com/ascend/modelzoo/tree/master/contrib/ACL_PyTorch/Research/cv/pose_estimation)。 -![image-20211209110458956](C:\Users\hwsc\AppData\Roaming\Typora\typora-user-images\image-20211209110458956.png) +![image-20211209110458956](.\imgs\image-20211209110458956.png) -关于模型分档,这里简要做下说明,具体可以参考:[昇腾社区文档](https://support.huaweicloud.com/onlineinfer-cann503alpha2training/atlasoiug_26_0013.html)。动态分档特性指的是模型支持有限个输入尺寸,且模型精度性能和单模型推理基本保持一致,转换后的动态模型结构如下: +关于模型分档,这里简要做下说明,具体可以参考:[昇腾社区文档](https://support.huaweicloud.com/onlineinfer-cann503alpha2training/atlasoiug_26_0013.html)。动态分档特性指的是模型支持有限个输入尺寸,且模型精度性能和单模型推理基本保持一致,转换后的动态模型结构如下图,其中Case表示不同输入的参数,另外模型的输入输出只显示最大的尺寸(1x3x1024x512; 1x34x256x128) -![image-20211209110458956](C:\Users\hwsc\AppData\Roaming\Typora\typora-user-images\image-20211209110458956.png) +​ ![image-20211209110458956](.\imgs\d14b7167-e835-4932-8e31-cf3adfafda75.png)![image-20211209110458956](.\imgs\ed7abd81-490d-4d96-af5e-1feb41756b41.png) ## 问题现象 @@ -46,15 +46,33 @@ 2. 动态分档模型推理 + ```shell + # 列举两种方式: + # 基于benchmark推理,需要给定具体的宽高,且和输入的数据对应 + ./benchmark.x86_64 --model_type=vision -batch_size=1 -device_id=2 -om_path=models/pose_higher_hrnet_w32_512_bs1_dynamic.om -input_text_path=sample_wgzheng_flip.info -useDvpp=false -output_binary=true -input_width=768 -input_height=512 + # 基于msame推理,需要给定具体的输入,且和输入的数据对应 + ./msame --model models/pose_higher_hrnet_w32_512_bs1_dynamic.om --input 'bs1_input_data' --dymDims "inputs:1,3,512,768" --output bs1_output + ``` + 3. 动态分档模型数据后处理 + 由于本模型的输出shape和输入shape是一一对应的,但是基于`msame`和`benchmark`工具的推理结果的shape是固定的(即默认输出最大尺寸的输出),需要进行截断操作: + + ```python + # 理论的输出shape为1*34*240*128,然后实际的输出为1*34*256*128(最大的尺寸),截断如下: + data = np.fromfile(path, dtype=np.float32)[: 1*34*240*128].reshape([1,34,240,128]) + ``` + -## 关于xxx问题的总结 +## 关于分档问题的总结 -概括整个解决方案,总结该案例得到的经验教训,如果有认为需要新增或者增强的功能需求,也可以在社区提issue并附上链接 ++ 分档方案适合动态输入但是数目有限(或者可以切分为有限)的场景 ++ 动态分档挡位不宜过多,尤其是对于大模型,可能导致性能下降 ++ 基于`benchmark/msame`的推理结果是基于最大输出shape得到的,必要时候需要进行截断 ## 附件 +无 \ No newline at end of file -- Gitee From 6879dc02b8a215041b2aff625eb80944a9983319 Mon Sep 17 00:00:00 2001 From: zheng-wengang1 Date: Thu, 9 Dec 2021 11:59:59 +0800 Subject: [PATCH 2/2] fix img bugs --- ...42\230\350\247\243\345\206\263\346\241\210\344\276\213.md" | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git "a/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" "b/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" index a509495..c47fa22 100644 --- "a/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" +++ "b/Ascend-PyTorch\347\246\273\347\272\277\346\216\250\347\220\206\346\214\207\345\257\274/\344\270\223\351\242\230\346\241\210\344\276\213/\345\212\237\350\203\275\346\211\223\351\200\232/HigherNet\346\250\241\345\236\213\345\212\250\346\200\201\345\210\206\346\241\243\351\227\256\351\242\230\350\247\243\345\206\263\346\241\210\344\276\213.md" @@ -6,11 +6,11 @@ [HigherNet](https://github.com/HRNet/HigherHRNet-Human-Pose-Estimation)出自CVPR2020,为经典的人体检测网络模型,基本算法框架见下图。HigherNet在推理过程中,输入图片的shape不是单一的固定输入,但是不是完全的动态,而是按照64(stride)倍数分为若干挡位,适合采用分档模型的方案。对应的代码可见:[modelzoo](https://gitee.com/ascend/modelzoo/tree/master/contrib/ACL_PyTorch/Research/cv/pose_estimation)。 -![image-20211209110458956](.\imgs\image-20211209110458956.png) +![image-20211209110458956](./imgs/image-20211209110458956.png) 关于模型分档,这里简要做下说明,具体可以参考:[昇腾社区文档](https://support.huaweicloud.com/onlineinfer-cann503alpha2training/atlasoiug_26_0013.html)。动态分档特性指的是模型支持有限个输入尺寸,且模型精度性能和单模型推理基本保持一致,转换后的动态模型结构如下图,其中Case表示不同输入的参数,另外模型的输入输出只显示最大的尺寸(1x3x1024x512; 1x34x256x128) -​ ![image-20211209110458956](.\imgs\d14b7167-e835-4932-8e31-cf3adfafda75.png)![image-20211209110458956](.\imgs\ed7abd81-490d-4d96-af5e-1feb41756b41.png) +​ ![image-20211209110458956](./imgs/d14b7167-e835-4932-8e31-cf3adfafda75.png)![image-20211209110458956](./imgs/ed7abd81-490d-4d96-af5e-1feb41756b41.png) ## 问题现象 -- Gitee