如何解决与输入形状尺寸有关的MRI分割错误conv2d层的输入0与该层不兼容
我正在尝试使用深度学习模型执行MRI分割,但出现与图像尺寸有关的错误,不确定原因。
import numpy as np
import nibabel as nib
import matplotlib.pyplot as plt
img = nib.load('/content/drive/My Drive/Programa2/P1_FL_final.nii.gz')
%matplotlib inline
img_np = img.get_fdata()
print(type(img_np),img_np.shape)
#Plotting slice of the image
img_slice= img.get_fdata()[:,:,20]
plt.imshow(img_slice,cmap='gray')
#Make prediction
img_analised=img_np
#img_analised=img_np[:,:] I was trying to change dimensions
print(img_analised.shape) #Image shape (480,512,30)
newmodel.predict(img_analised)
错误消息
ValueError: Input 0 of layer conv2d is incompatible with the layer: : expected min_ndim=4,found ndim=3. Full shape received: [32,30]
解决方法
问题与输入图像的形状有关,代码要求MRI的4种不同形式,而我使用的形式较少。当我更改它时,就可以了。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。