PaddleSeg icon indicating copy to clipboard operation
PaddleSeg copied to clipboard

[General Issue]验证时报错:ValueError: Shape of `pred` and `label should be equal, but there are [1, 256, 384] and [1, 1, 256, 384, 3].

Open Viktorjc98 opened this issue 3 years ago • 1 comments

Thanks for your issue. To help us solve the issue better, please provide following information:

  1. PaddleSeg version: (please specify the branch as well,e.g. PaddleSeg release/2.3)
  2. PaddlePaddle version: (e.g. PaddlePaddle 2.1.0)
  3. Operation system: (e.g. Linux/Windows/MacOS)
  4. Python version: (e.g. Python3.6/7/8)
  5. CUDA/cuDNN version: (e.g. CUDA10.2/cuDNN 7.6.5)
  6. Additional context: (Add any other context about the problem)

欢迎您反馈PaddleSeg使用问题,辛苦您提供以下信息,方便我们快速定位和解决问题:

  1. PaddleSeg版本:最新(请提供版本号和分支信息,如PaddleSeg release/2.3)
  2. PaddlePaddle版本:2.2.2(如PaddlePaddle 2.1.0)
  3. 操作系统信息:(如Linux/Windows/MacOS)
  4. Python版本号:(如Python3.6/7/8)
  5. CUDA/cuDNN版本:CUDA10.1( 如CUDA10.2/cuDNN 7.6.5等)
  6. 其他内容: (增加其他与问题相关的内容)

batch_size: 2 iters: 41000 loss: coef:

  • 1
  • 0.4
  • 0.4
  • 0.4 types:
  • type: CrossEntropyLoss
  • type: CrossEntropyLoss
  • type: CrossEntropyLoss
  • type: CrossEntropyLoss lr_scheduler: end_lr: 0.0001 learning_rate: 6.0e-05 power: 0.9 type: PolynomialDecay model: align_corners: true backbone: pretrained: https://bj.bcebos.com/paddleseg/dygraph/vit_large_patch16_384.tar.gz type: ViT_large_patch16_384 backbone_indices:
  • 9
  • 14
  • 19
  • 23 head: naive num_classes: 2 type: SegmentationTransformer optimizer: momentum: 0.9 type: sgd weight_decay: 0.0 test_config: crop_size:
  • 769
  • 769 is_slide: true stride:
  • 512
  • 512 train_dataset: dataset_root: /home/aistudio/data/data163754 mode: train num_classes: 2 train_path: /home/aistudio/data/data163754/val.txt transforms:
  • max_scale_factor: 2.0 min_scale_factor: 0.25 scale_step_size: 0.25 type: ResizeStepScaling
  • crop_size:
    • 769
    • 769 type: RandomPaddingCrop
  • type: RandomHorizontalFlip
  • brightness_range: 0.5 contrast_range: 0.5 saturation_range: 0.5 type: RandomDistort
  • type: Normalize type: Dataset val_dataset: dataset_root: /home/aistudio/data/data163754 mode: val num_classes: 2 transforms:
  • target_size:
    • 2048
    • 1024 type: Padding
  • type: Normalize type: Dataset val_path: /home/aistudio/data/data163754/val.txt

W0811 11:41:24.330037 6934 device_context.cc:447] Please NOTE: device: 0, GPU Compute Capability: 7.0, Driver API Version: 11.2, Runtime API Version: 10.1 W0811 11:41:24.330083 6934 device_context.cc:465] device: 0, cuDNN Version: 7.6. 2022-08-11 11:41:27 [INFO] Loading pretrained model from https://bj.bcebos.com/paddleseg/dygraph/vit_large_patch16_384.tar.gz 2022-08-11 11:41:36 [INFO] There are 292/292 variables loaded into VisionTransformer. 2022-08-11 11:41:45 [INFO] Loading pretrained model from output/iter_40000/model.pdparams 2022-08-11 11:41:47 [INFO] There are 332/332 variables loaded into SegmentationTransformer. 2022-08-11 11:41:47 [INFO] Loaded trained params of model successfully 2022-08-11 11:41:47 [INFO] Start evaluating (total_samples: 920, total_iters: 920)... /home/aistudio/PaddleSeg/paddleseg/core/infer.py:98: DeprecationWarning: np.int is a deprecated alias for the builtin int. To silence this warning, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations rows = np.int(np.ceil(1.0 * (h_im - h_crop) / h_stride)) + 1 /home/aistudio/PaddleSeg/paddleseg/core/infer.py:99: DeprecationWarning: np.int is a deprecated alias for the builtin int. To silence this warning, use int by itself. Doing this will not modify any behavior and is safe. When replacing np.int, you may wish to use e.g. np.int64 or np.int32 to specify the precision. If you wish to review your current use, check the release note link for additional information. Deprecated in NumPy 1.20; for more details and guidance: https://numpy.org/devdocs/release/1.20.0-notes.html#deprecations cols = np.int(np.ceil(1.0 * (w_im - w_crop) / w_stride)) + 1 Traceback (most recent call last): File "val.py", line 187, in main(args) File "val.py", line 182, in main evaluate(model, val_dataset, num_workers=args.num_workers, **test_config) File "/home/aistudio/PaddleSeg/paddleseg/core/val.py", line 165, in evaluate ignore_index=eval_dataset.ignore_index) File "/home/aistudio/PaddleSeg/paddleseg/utils/metrics.py", line 43, in calculate_area label.shape)) ValueError: Shape of pred and `label should be equal, but there are [1, 256, 384] and [1, 1, 256, 384, 3].

Viktorjc98 avatar Aug 11 '22 03:08 Viktorjc98

请问您使用的是自定义数据集吗?如果是的话,请您检查标签是否为单通道(现在的情况标签有可能是三通道的图像)。

Bobholamovic avatar Aug 11 '22 06:08 Bobholamovic

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.

github-actions[bot] avatar Dec 05 '22 17:12 github-actions[bot]