mirror of
https://github.com/open-mmlab/mmdeploy.git
synced 2025-01-14 08:09:43 +08:00
Add mmseg configs for compatibility with Fast-SCNN model in ncnn backend (#1094)
* mmdeploy summer camp * fix lint * add note * add note * add a comment in interpolate.py Co-authored-by: root <root@LAPTOP-A20M40H8.localdomain>
This commit is contained in:
parent
2d35c9ab35
commit
b6f8c1c50d
3
configs/mmseg/segmentation_ncnn-int8_static-1024x2048.py
Normal file
3
configs/mmseg/segmentation_ncnn-int8_static-1024x2048.py
Normal file
@ -0,0 +1,3 @@
|
||||
_base_ = ['./segmentation_static.py', '../_base_/backends/ncnn-int8.py']
|
||||
|
||||
onnx_config = dict(input_shape=[2048, 1024])
|
@ -47,3 +47,14 @@ Note: MMPose models are tested with `flip_test` explicitly set to `False` in mod
|
||||
| :-----------------------------------------------------------------------------------------------------------------: | :-----: | :------------: | :------------: |
|
||||
| [EDSRx2](https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edsr/edsr_x2c64b16_g1_300k_div2k.py) | Set5 | 35.7733/0.9365 | 35.4266/0.9334 |
|
||||
| [EDSRx4](https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edsr/edsr_x4c64b16_g1_300k_div2k.py) | Set5 | 30.2194/0.8498 | 29.9340/0.8409 |
|
||||
|
||||
### mmseg
|
||||
|
||||
| model | dataset | fp32 mIoU | int8 mIoU |
|
||||
| :----------------------------------------------------------------------------------------------------------------------------: | :--------: | :-------: | :-------: |
|
||||
| [Fast-SCNN](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastscnn/fast_scnn_lr0.12_8x4_160k_cityscapes.py) | cityscapes | 70.96 | 70.24 |
|
||||
|
||||
Note:
|
||||
|
||||
- Int8 models of the Fast-SCNN requires ncnnoptimize.
|
||||
- NCNN will extract 512 images from the train as a calibration dataset
|
||||
|
@ -47,3 +47,14 @@
|
||||
| :-----------------------------------------------------------------------------------------------------------------: | :-----: | :------------: | :------------: |
|
||||
| [EDSR](https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edsr/edsr_x2c64b16_g1_300k_div2k.py) | Set5 | 35.7733/0.9365 | 35.4266/0.9334 |
|
||||
| [EDSRx4](https://github.com/open-mmlab/mmediting/blob/master/configs/restorers/edsr/edsr_x4c64b16_g1_300k_div2k.py) | Set5 | 30.2194/0.8498 | 29.9340/0.8409 |
|
||||
|
||||
### 语义分割任务
|
||||
|
||||
| model | dataset | fp32 mIoU | int8 mIoU |
|
||||
| :----------------------------------------------------------------------------------------------------------------------------: | :--------: | :-------: | :-------: |
|
||||
| [Fast-SCNN](https://github.com/open-mmlab/mmsegmentation/blob/master/configs/fastscnn/fast_scnn_lr0.12_8x4_160k_cityscapes.py) | cityscapes | 70.96 | 70.24 |
|
||||
|
||||
备注:
|
||||
|
||||
- Fast-SCNN 的int8模型需要使用ncnnoptimize优化。
|
||||
- NCNN将会从train中抽取512张图片作为校准集。
|
||||
|
@ -22,13 +22,16 @@ def interpolate__ncnn(ctx,
|
||||
"""Rewrite `interpolate` for ncnn backend.
|
||||
|
||||
ncnn require `size` should be constant in ONNX Node. We use `scale_factor`
|
||||
instead of `size` to avoid dynamic size.
|
||||
instead of `size` to avoid dynamic size. To avoid rounding errors, add a
|
||||
small number when `scale_factor` is not an integer
|
||||
"""
|
||||
|
||||
input_size = input.shape
|
||||
if scale_factor is None:
|
||||
scale_factor = [
|
||||
s_out / s_in for s_out, s_in in zip(size, input_size[2:])
|
||||
s_out / s_in if int(s_out / s_in) == s_out / s_in else
|
||||
(s_out / s_in + 0.00001)
|
||||
for s_out, s_in in zip(size, input_size[2:])
|
||||
]
|
||||
|
||||
return ctx.origin_func(
|
||||
|
@ -10,4 +10,8 @@ def adaptive_avg_pool2d__ncnn(ctx, g, x, output_size):
|
||||
|
||||
Align symbolic of adaptive_avg_pool2d in ncnn.
|
||||
"""
|
||||
return g.op('mmdeploy::AdaptiveAvgPool2d', x, output_size)
|
||||
size = getattr(output_size.node(), 't')('value').tolist()
|
||||
if size != [1, 1]:
|
||||
return g.op('mmdeploy::AdaptiveAvgPool2d', x, output_size)
|
||||
else:
|
||||
return g.op('GlobalAveragePool', x)
|
||||
|
Loading…
x
Reference in New Issue
Block a user