PaddleOCR icon indicating copy to clipboard operation
PaddleOCR copied to clipboard

知识蒸馏

Open LiquorPerfect opened this issue 3 years ago • 3 comments

问题1: 对rec模型使用知识蒸馏,ch_PP-OCRv2_rec_distillation.yml配置文件中Backbone为MobileNetV3、MobileNetV1Enhance时不会报错。 将backbone修改为ResNet_系列时,会出现参数已经已经在使用的情况。 image

Traceback (most recent call last): File "tools/train.py", line 130, in main(config, device, logger, vdl_writer) File "tools/train.py", line 82, in main model = build_model(config['Architecture']) File "/PaddleOCR-release-2.3/ppocr/modeling/architectures/init.py", line 31, in build_model arch = getattr(mod, name)(config) File "/PaddleOCR-release-2.3/ppocr/modeling/architectures/distillation_model.py", line 48, in init model = BaseModel(model_config) File "/PaddleOCR-release-2.3/ppocr/modeling/architectures/base_model.py", line 50, in init self.backbone = build_backbone(config["Backbone"], model_type) File "/PaddleOCR-release-2.3/ppocr/modeling/backbones/init.py", line 47, in build_backbone module_class = eval(module_name)(**config) File "/PaddleOCR-release-2.3/ppocr/modeling/backbones/rec_resnet_vd.py", line 200, in init self.conv1_1 = ConvBNLayer( File "/PaddleOCR-release-2.3/ppocr/modeling/backbones/rec_resnet_vd.py", line 43, in init self._conv = nn.Conv2D( File "/root/anaconda3/envs/paddle_2.2.0_gpu/lib/python3.8/site-packages/paddle/nn/layer/conv.py", line 643, in init super(Conv2D, self).init( File "/root/anaconda3/envs/paddle_2.2.0_gpu/lib/python3.8/site-packages/paddle/nn/layer/conv.py", line 132, in init self.weight = self.create_parameter( File "/root/anaconda3/envs/paddle_2.2.0_gpu/lib/python3.8/site-packages/paddle/fluid/dygraph/layers.py", line 423, in create_parameter return self._helper.create_parameter(temp_attr, shape, dtype, is_bias, File "/root/anaconda3/envs/paddle_2.2.0_gpu/lib/python3.8/site-packages/paddle/fluid/layer_helper_base.py", line 368, in create_parameter raise ValueError( ValueError: parameter name [conv1_1_weights] have be been used. In dygraph mode, the name of parameter can't be same.Please check the parameter attr value passed to self.create_parameter or constructor of dygraph Layers INFO 2021-12-15 12:03:30,308 launch_utils.py:338] terminate all the procs ERROR 2021-12-15 12:03:30,308 launch_utils.py:599] ABORT!!! Out of all 2 trainers, the trainer process with rank=[0, 1] was aborted. Please check its log. INFO 2021-12-15 12:03:34,312 launch_utils.py:338] terminate all the procs INFO 2021-12-15 12:03:34,313 launch.py:285] Local processes completed. 希望验证下告诉结果,以及导致的原因

问题2: image 将teacher和student都配置一样预训练模型,使用DML相互学习模式,不固定参数,从结果来看,加载预训练模型对精度提升没有效果。

问题3: 模型先剪枝后蒸馏,是否有教程。对剪枝后保存的best_accuracy模型,知识蒸馏应该怎么使用。

LiquorPerfect avatar Dec 15 '21 12:12 LiquorPerfect

试一下最新代码,应该已经解决了

WenmuZhou avatar Dec 16 '21 23:12 WenmuZhou

@WenmuZhou 你说的最新的代码时 release2.4的还是release2.3的。

LiquorPerfect avatar Dec 23 '21 01:12 LiquorPerfect

@LiquorPerfect 我想请教一下,我使用蒸馏训练det的时候,想要看一下训练效果时候图片不显示,是方法有问题吗?所以想问一下,对于训练过的模型怎么使用

Jackzhangfei avatar Aug 11 '22 13:08 Jackzhangfei

试一下最新代码,应该已经解决了

可以帮忙提供一下能跑通的resnet distillation yml文件吗?

nissansz avatar May 10 '23 22:05 nissansz