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++网络推理出错 #812

Closed keepgoing365 closed 1 year ago

keepgoing365 commented 3 years ago

2021-01-29 16:03:04 [INFO] Start to predict... Traceback (most recent call last): File "predict.py", line 172, in main(args) File "predict.py", line 166, in main stride=args.stride, File "I:\github_project\PaddleSeg-release-v2.0.0-rc\paddleseg\core\predict.py", line 103, in predict crop_size=crop_size) File "I:\github_project\PaddleSeg-release-v2.0.0-rc\paddleseg\core\infer.py", line 169, in inference logits = model(im) File "E:\Anaconda1\envs\PaddleSeg\lib\site-packages\paddle\fluid\dygraph\layers.py", line 884, in call outputs = self.forward(*inputs, *kwargs) File "I:\github_project\PaddleSeg-release-v2.0.0-rc\paddleseg\models\unet_plusplus.py", line 157, in forward X0_1 = self.up_cat0_1(X1_0, X0_0) # n,32,h,w File "E:\Anaconda1\envs\PaddleSeg\lib\site-packages\paddle\fluid\dygraph\layers.py", line 884, in call outputs = self.forward(inputs, kwargs) File "I:\github_project\PaddleSeg-release-v2.0.0-rc\paddleseg\models\unet_plusplus.py", line 233, in forward cat_features = paddle.concat(features, axis=1) File "E:\Anaconda1\envs\PaddleSeg\lib\site-packages\paddle\tensor\manipulation.py", line 113, in concat return paddle.fluid.layers.concat(input=x, axis=axis, name=name) File "E:\Anaconda1\envs\PaddleSeg\lib\site-packages\paddle\fluid\layers\tensor.py", line 300, in concat return core.ops.concat(input, 'axis', axis) ValueError: (InvalidArgument) The 2-th dimension of input[0] and input[1] is expected to be equal.But received input[0]'s shape = [1, 32, 1494, 2242], input[1]'s shape = [1, 32, 1495, 2243].**

[Hint: If you need C++ stacktraces for debugging, please set FLAGS_call_stack_level=2.] [operator < concat > error] 报错如上,我试了其他模型都可以推理。唯独unet++模型不能推理,但是可以正常训练。有朋友知道怎么解决这个问题或者怎么调试吗?

haoyuying commented 3 years ago

看报错信息,应该是某一张图片在提取特征concate时候两个大小不一致导致的,训练的时候由于crop到同一大小因此不会出错,建议您能将推理时的报错图片发给我们,如果对精度要求不高,也可以将传入的数据resize或者crop一下。

keepgoing365 commented 3 years ago

可以将传入的数据resize或者crop一下。 感谢大哥。你是说把报错信息发给你吗?完整x信息在这里,麻烦大哥帮忙解决下,感激不尽!

image

keepgoing365 commented 3 years ago

@haoyuying 麻烦大哥帮我看下呢

haoyuying commented 3 years ago

您好同学,我想要的图片是你在eval时候出错的图片,可以把图片发给我,或者开放个网盘地址我好下载出问题的图片复现问题。

keepgoing365 commented 3 years ago

我想要的图片是你在eval时候出错的图片

我找到问题的原因了,应该是我训练图片的时候 RandomPaddingCrop :crop_size设置得比训练集尺寸大导致的。我重新设置这个参数然后从头开始训练出来就可以推理了,多谢啦