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

unet_3plus 训练错误问题 #1174

Closed sddnuaa closed 1 year ago

sddnuaa commented 3 years ago

from paddleseg.models import UNet3Plus,在定义model = UNet3Plus(in_channels=3, num_classes=2)能正常训练,打开deepsup和CSM,model = UNet3Plus(in_channels=3, num_classes=2, is_deepsup=True, is_CGM=True),训练报错。

报错代码如下: /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dataloader/dataloaderiter.py:89: DeprecationWarning: np.bool is a deprecated alias for the builtin bool. To silence this warning, use bool by itself. Doing this will not modify any behavior and is safe. If you specifically wanted the numpy scalar type, use `np.bool` here. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations if isinstance(slot[0], (np.ndarray, np.bool, numbers.Number)): /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/math_op_patch.py:238: UserWarning: The dtype of left and right variables are not the same, left dtype is VarType.FP64, but right dtype is VarType.FP32, the right dtype will convert to VarType.FP64 format(lhs_dtype, rhs_dtype, lhs_dtype)) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddle/fluid/dygraph/math_op_patch.py:238: UserWarning: The dtype of left and right variables are not the same, left dtype is VarType.FP32, but right dtype is VarType.FP64, the right dtype will convert to VarType.FP32 format(lhs_dtype, rhs_dtype, lhs_dtype)) ---------------------------------------------------------------------------RuntimeError Traceback (most recent call last) in 17 num_workers=0, 18 losses=losses, ---> 19 use_vdl=True) /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/core/train.py in train(model, train_dataset, val_dataset, optimizer, save_dir, iters, batch_size, resume_model, save_interval, log_iters, num_workers, use_vdl, losses, keep_checkpoint_max, test_config, fp16) 183 labels=labels, 184 losses=losses, --> 185 edges=edges) 186 loss = sum(loss_list) 187 loss.backward() /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/core/train.py in loss_computation(logits_list, labels, losses, edges) 35 36 def loss_computation(logits_list, labels, losses, edges=None): ---> 37 check_logits_losses(logits_list, losses) 38 loss_list = [] 39 for i in range(len(logits_list)): /opt/conda/envs/python35-paddle120-env/lib/python3.7/site-packages/paddleseg/core/train.py in check_logits_losses(logits_list, losses) 31 raise RuntimeError( 32 'The length of logits_list should equal to the types of loss config: {} != {}.' ---> 33 .format(len_logits, len_losses)) 34 35 RuntimeError: The length of logits_list should equal to the types of loss config: 5 != 1.

请哪位大神帮忙解决一下?

nepeplwu commented 3 years ago

@sddnuaa 从报错日志来看,应该是UNet3P只有一个输出,但是你的配置文件里面配置了5个Loss

sddnuaa commented 3 years ago

谢谢,已解决

conlaysmile commented 3 years ago

谢谢,已解决

您好,我也碰到同样的问题了,想请问下是怎么解决的?

sddnuaa commented 3 years ago

打开deepsup和CSM后,需要根据输入情况配置loss个数 @conlaysmile

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.