The image produced is not valid

The image produced is not valid  

  By: fangyijie.wang on Aug. 5, 2023, 5:41 p.m.

Hi,

My docker image saved the predicted segmentation mask as mha image, but it gets the error: The image produced in 'images/symphysis-segmentation' is not valid The log shows as below: [load_model] Model loaded on CUDA [process] Received 1 input images /input/images/pelvic-2d-ultrasound/33920321-c51e-4468-9b0c-b4ec6ff5ed85.mha [process] loaded /input/images/pelvic-2d-ultrasound/33920321-c51e-4468-9b0c-b4ec6ff5ed85.mha [process] convert image to torch.Size([1, 3, 256, 256]) tensor [process] get prediction result: (256, 256) [write_outputs] image was saved to the target path /output/images/symphysis-segmentation/33920321-c51e-4468-9b0c-b4ec6ff5ed85.mha

I followed the instruction that "prediction images with a size of 256x256 are accepted. The prediction images can only contain pixels labeled as 0, 1, or 2, with 0 representing the background, 1 representing the pubic symphysis, and 2 representing the fetal head." Does anyone know the reason for this error ?

Re: The image produced is not valid  

  By: 坤坤kk on Aug. 10, 2023, 12:05 a.m.

Hello, I also got the same error as you, did you solve it?

Re: The image produced is not valid  

  By: fangyijie.wang on Aug. 11, 2023, 8:42 p.m.

I solved the issue by converting the predicted data array to unit8 data type before saving as an image. My code is as below:

pred_img = SimpleITK.GetImageFromArray(numpy.uint8(img_array))

Re: The image produced is not valid  

  By: 坤坤kk on Aug. 12, 2023, 7:15 a.m.

Thank you very much, I have submitted successfully!!