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.74k stars 1.68k forks source link

[Bug] 在aistudio上实例化模型出错,之前是可以的,但是现在不可以了 #2120

Closed anzx2452 closed 3 weeks ago

anzx2452 commented 2 years ago

通过pip install paddleseg 安装默认版本 --> model = paddleseg.models.segformer.SegFormer_B2(num_classes=4) 出错

错误输出:

OSError Traceback (most recent call last) /tmp/ipykernel_202/4247776124.py in ----> 1 model = paddleseg.models.segformer.SegFormer_B2(num_classes=4) 2 3 # 设置学习率 4 base_lr = 0.05 5 lr = paddle.optimizer.lr.PolynomialDecay(base_lr, power=0.9, decay_steps=80000, end_lr=0.002)

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/models/segformer.py in SegFormer_B2(kwargs) 149 def SegFormer_B2(kwargs): 150 return SegFormer( --> 151 backbone=manager.BACKBONES['MixVisionTransformer_B2'](), 152 embedding_dim=768, 153 **kwargs)

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/models/backbones/mix_transformer.py in MixVisionTransformer_B2(kwargs) 540 drop_rate=0.0, 541 drop_path_rate=0.1, --> 542 kwargs) 543 544

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/models/backbones/mix_transformer.py in init(self, img_size, patch_size, in_chans, num_classes, embed_dims, num_heads, mlp_ratios, qkv_bias, qk_scale, drop_rate, attn_drop_rate, drop_path_rate, norm_layer, depths, sr_ratios, pretrained) 286 stride=4, 287 in_chans=in_chans, --> 288 embed_dim=embed_dims[0]) 289 self.patch_embed2 = OverlapPatchEmbed( 290 img_size=img_size // 4,

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/models/backbones/mix_transformer.py in init(self, img_size, patch_size, stride, in_chans, embed_dim) 227 kernel_size=patch_size, 228 stride=stride, --> 229 padding=(patch_size[0] // 2, patch_size[1] // 2)) 230 self.norm = nn.LayerNorm(embed_dim) 231

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/conv.py in init(self, in_channels, out_channels, kernel_size, stride, padding, dilation, groups, padding_mode, weight_attr, bias_attr, data_format) 654 weight_attr=weight_attr, 655 bias_attr=bias_attr, --> 656 data_format=data_format) 657 658 def forward(self, x):

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/nn/layer/conv.py in init(self, in_channels, out_channels, kernel_size, transposed, dims, stride, padding, padding_mode, output_padding, dilation, groups, weight_attr, bias_attr, data_format) 133 shape=filter_shape, 134 attr=self._param_attr, --> 135 default_initializer=_get_default_param_initializer()) 136 self.bias = self.create_parameter( 137 attr=self._bias_attr, shape=[self._out_channels], is_bias=True)

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/layers.py in create_parameter(self, shape, attr, dtype, is_bias, default_initializer) 420 temp_attr = None 421 return self._helper.create_parameter(temp_attr, shape, dtype, is_bias, --> 422 default_initializer) 423 424 @deprecated(

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/layer_helper_base.py in create_parameter(self, attr, shape, dtype, is_bias, default_initializer, stop_gradient, type) 376 type=type, 377 stop_gradient=stop_gradient, --> 378 **attr._to_kwargs(with_initializer=True)) 379 else: 380 self.startup_program.global_block().create_parameter(

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py in create_parameter(self, *args, **kwargs) 3135 pass 3136 else: -> 3137 initializer(param, self) 3138 return param 3139

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/initializer.py in call(self, var, block) 360 "use_mkldnn": False 361 }, --> 362 stop_gradient=True) 363 364 if var.dtype in [VarDesc.VarType.FP16, VarDesc.VarType.BF16]:

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/framework.py in append_op(self, *args, **kwargs) 3165 kwargs.get("outputs", {}), attrs 3166 if attrs else {}, -> 3167 kwargs.get("stop_gradient", False)) 3168 else: 3169 from paddle.fluid.dygraph.base import param_guard

/opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/tracer.py in trace_op(self, type, inputs, outputs, attrs, stop_gradient) 43 self.trace(type, inputs, outputs, attrs, 44 framework._current_expected_place(), self._has_grad and ---> 45 not stop_gradient) 46 47 def train_mode(self):

OSError: [operator < gaussian_random > error]

TingquanGao commented 3 weeks ago

Thanks for this issue. As it has been inactive for a long time, we would close it. If you has any questions, please feel free to reopen or new issue, and we will follow up and resolve it.