PaddlePaddle / PaddleSeg

Easy-to-use image segmentation library with awesome pre-trained model zoo, supporting wide-range of practical tasks in Semantic Segmentation, Interactive Segmentation, Panoptic Segmentation, Image Matting, 3D Segmentation, etc.
https://arxiv.org/abs/2101.06175
Apache License 2.0
8.71k stars 1.68k forks source link

ocrnet+movilenetv3加载pretrained模型异常 #1329

Closed bbbxixixixi closed 1 year ago

bbbxixixixi commented 3 years ago

aistudio环境, paddleseg2.2

model的配置如下 model: type: OCRNet backbone: type: MobileNetV3_small_x1_0 pretrained: https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar num_classes: 2 backbone_indices: [0]

异常信息 2021-09-08 11:23:51 [INFO] Loading pretrained model from https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar Connecting to https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar Downloading MobileNetV3_small_x1_0_ssld_pretrained.tar [==================================================] 100.00% Uncompress MobileNetV3_small_x1_0_ssld_pretrained.tar [==================================================] 100.00% Traceback (most recent call last): File "/home/aistudio/PaddleSeg-release-2.2-trim/train.py", line 190, in main(args) File "/home/aistudio/PaddleSeg-release-2.2-trim/train.py", line 170, in main cfg.model, File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/cvlibs/config.py", line 291, in model self._model = self._load_object(model_cfg) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/cvlibs/config.py", line 349, in _load_object params[key] = self._load_object(val) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/cvlibs/config.py", line 358, in _load_object return component(params) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 332, in MobileNetV3_small_x1_0 model = MobileNetV3(model_name="small", scale=1.0, kwargs) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 159, in init self.init_weight() File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 189, in init_weight utils.load_pretrained_model(self, self.pretrained) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/utils/utils.py", line 94, in load_pretrained_model pretrained_model)) ValueError: The pretrained model directory is not Found: /home/aistudio/.paddleseg/pretrained_model/MobileNetV3_small_x1_0_ssld_pretrained/model.pdparams

michaelowenliu commented 3 years ago

@bbbxixixixi Hi, if the pdparams has not been downloaded properly, please download it into the local directory manually.

bbbxixixixi commented 3 years ago

@bbbxixixixi Hi, if the pdparams has not been downloaded properly, please download it into the local directory manually.

I downloaded the tar file and change model config to model:   type: OCRNet   backbone:     type: MobileNetV3_small_x1_0     pretrained: /home/aistudio/MobileNetV3_small_x1_0_ssld_pretrained.tar   num_classes: 2   backbone_indices: [0]

error occurs ValueError: paddle.load can not parse the file:/home/aistudio/MobileNetV3_small_x1_0_ssld_pretrained.tar.

I unzip the tar file to a folder. It contains many weights files like conv9_expand_bn_scale. I change the config to model:   type: OCRNet   backbone:     type: MobileNetV3_small_x1_0     pretrained: /home/aistudio/MobileNetV3_small_x1_0_ssld_pretrained   num_classes: 2   backbone_indices: [0]

error occurs 2021-09-08 16:10:19 [WARNING] conv12.linear_conv.bn._mean is not in pretrained model 2021-09-08 16:10:19 [WARNING] conv12.linear_conv.bn._variance is not in pretrained model 2021-09-08 16:10:19 [INFO] There are 0/206 variables loaded into MobileNetV3. /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/norm.py:641: UserWarning: When training, we now always track global mean and variance. "When training, we now always track global mean and variance.") Traceback (most recent call last): File "/home/aistudio/PaddleSeg-release-2.2-trim/train.py", line 190, in main(args) File "/home/aistudio/PaddleSeg-release-2.2-trim/train.py", line 185, in main fp16=args.fp16) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/core/train.py", line 188, in train logits_list = model(images) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 902, in call outputs = self.forward(*inputs, kwargs) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/ocrnet.py", line 71, in forward feats = self.backbone(x) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 902, in call outputs = self.forward(*inputs, *kwargs) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 181, in forward x = block(x) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 902, in call outputs = self.forward(inputs, kwargs) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 282, in forward x = self.mid_se(x) File "/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py", line 902, in call outputs = self.forward(*inputs, **kwargs) File "/home/aistudio/PaddleSeg-release-2.2-trim/paddleseg/models/backbones/mobilenetv3.py", line 311, in forward outputs = F.hard_sigmoid(outputs) AttributeError: module 'paddle.nn.functional' has no attribute 'hard_sigmoid'

there are no pretrained variables loaded. The pretrained model link ' https://paddle-imagenet-models-name.bj.bcebos.com/MobileNetV3_small_x1_0_ssld_pretrained.tar' is from legacy/pretrained_model/download_model.py. It may not be suitable for current version 2.2. Do you have a new pretrained model file format for version 2.2? And another problem is hard_sigmoid, aistudio paddle version is 2.1.2 python 3.7. Maybe the movilev3 backbone is not functional under current version?

michaelowenliu commented 3 years ago

@bbbxixixixi Hi, currently we have not provided the pretrained model. You may download it from PaddleClas, https://github.com/PaddlePaddle/Paddleclas/tree/dygraph-dev#Mobile_series

bbbxixixixi commented 3 years ago

@bbbxixixixi Hi, currently we have not provided the pretrained model. You may download it from PaddleClas, https://github.com/PaddlePaddle/Paddleclas/tree/dygraph-dev#Mobile_series

the pretrained model is ok

some codes in mobilenetv3.py need to modify

line 311 outputs = F.hard_sigmoid(outputs) return paddle.multiply(x=inputs, y=outputs, axis=0) should be outputs = F.hardsigmoid(outputs) return paddle.multiply(x=inputs, y=outputs)

michaelowenliu commented 3 years ago

@bbbxixixixi Yes, the paddle api is changed in recent versions. Could you please submit the modification PR? Thanks.

bbbxixixixi commented 3 years ago

@bbbxixixixi Yes, the paddle api is changed in recent versions. Could you please submit the modification PR? Thanks.

https://github.com/PaddlePaddle/PaddleSeg/pull/1332

michaelowenliu commented 3 years ago

@bbbxixixixi Yes, the paddle api is changed in recent versions. Could you please submit the modification PR? Thanks.

1332

@bbbxixixixi Thanks. Could you sign Contributor License Agreement before merging you pr?

bbbxixixixi commented 3 years ago

@bbbxixixixi Yes, the paddle api is changed in recent versions. Could you please submit the modification PR? Thanks.

1332

@bbbxixixixi Thanks. Could you sign Contributor License Agreement before merging you pr?

done

github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.