PaddlePaddle / PaddleSlim

PaddleSlim is an open-source library for deep model compression and architecture search.
https://paddleslim.readthedocs.io/zh_CN/latest/
Apache License 2.0
1.56k stars 345 forks source link

量化ch_PP-OCRv4_det后导出报错 #1884

Open aijim opened 4 months ago

aijim commented 4 months ago

环境: Ubantu 20.04 paddlepaddle-gpu 2.6.1 paddleslim 2.3.2

你好! 我用quant.py量化ch_PP-OCRv4_det后,用export_model.py导出模型的时候出错。好像是每层Conv2D都加了一层MAOutputScaleLayer,而export_model.py期望不加MAOutputScaleLayer的Conv2D层。有解决的方法么?

Traceback (most recent call last):
  File "/home/shui/ascent-paddleocr/deploy/slim/quantization/export_model.py", line 179, in <module>
    main()
  File "/home/shui/ascent-paddleocr/deploy/slim/quantization/export_model.py", line 173, in main
    export_single_model(model, arch_config, save_path, logger, input_shape,
  File "/home/shui/ascent-paddleocr/tools/export_model.py", line 196, in export_single_model
    layer.rep()
  File "/home/shui/ascent-paddleocr/ppocr/modeling/backbones/rec_lcnetv3.py", line 201, in rep
    kernel, bias = self._get_kernel_bias()
  File "/home/shui/ascent-paddleocr/ppocr/modeling/backbones/rec_lcnetv3.py", line 220, in _get_kernel_bias
    kernel_conv_1x1, bias_conv_1x1 = self._fuse_bn_tensor(self.conv_1x1)
  File "/home/shui/ascent-paddleocr/ppocr/modeling/backbones/rec_lcnetv3.py", line 244, in _fuse_bn_tensor
    kernel = branch.conv.weight
  File "/home/shui/.local/lib/python3.10/site-packages/paddle/nn/layer/layers.py", line 1657, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'MAOutputScaleLayer' object has no attribute 'weight'
ArthurisYun commented 3 months ago

我也遇到这问题 请问解决了么

piupuer commented 1 week ago

我也遇到这个问题, 用的是paddle3.0.0beta, paddleslim develop, paddleocr develop