paddlepaddle ValueError: Mask should be a 1-channel image, but recevied is a 4-channel image.
1. Error related environment
Using paddlepaddle the environment, the above error message is displayed
使用自己的数据集报错,他们的数据没有问题
Error details
2. Error analysis
2.1 View channel
According to the error report, it is said that the picture should be 1通道, and my data is4通道
Find the number of lines that reported the error
Print your own data image dimensions
I am(256,256,4),4通道
Printing does not report an error data picture dimension
yes(256,256),1通道
2.2 View Mode
print your own picturemode
forRGBA
Print no error data picturemode
for1
3. Solutions
will be 4通道changed 1通道, will be modechanged1
Baidu search mode will RGBAbe changed to1
convertJust use the function
Image.open(img_name).convert('1')
The number of channels and modethe reason should be corresponding, the error has been resolved, and I don’t care about the relationship between them,,,
Project-related file code modification
mask=np.asarray(Image.open(mask).convert('1'))
Finish! ! !
4. Supplement [later supplement]
After the conversion 1, the mask read by the model training msakis all black, resulting in no prediction, so it should be converted to L, not converted to1
mask=np.asarray(Image.open(mask).convert('L'))
5. Summary
There is another error in the command line of the error
SystemError: (Fatal) Blocking queue is killed because the data reader raises an exception. [Hint: Expected killed_ != true, but received killed_:1 == true:1.] (at /paddle/paddle/fluid/operators/read
Baidu can't find a solution, it's a mess, I found that the above error should be solved better, so I don't care
The last error was resolved, and this error is gone,,,