【发布时间】:2023-03-10 20:17:01
【问题描述】:
这是血细胞的分类过程。我有 2 个课程:单核和多核。培训完成。 X_test 是图像数组,y_test 是标签数组。我正在尝试预测单个输入图像的标签。
我已将标签数组更改为 dtype int 并在 float32 中展平它和图像数组,就像我对训练图像和标签所做的那样。我是否需要像使用 DatasetMixin 制作训练数据集一样制作测试数据集?以及如何获得所需的结果。我只针对单个图像预测。
y_test = y_test.astype(int)
y_test = y_test.flatten()
batch_size = 1
dataset = MyDataset(X_test, y_test)
test_iter = iterators.SerialIterator(dataset, batch_size)
img = cv2.imread('C:/Users/Dell/Desktop/TEST IMAGES/MONOCYTE.jpeg')
plt.imshow(img)
plt.show()
img=np.array((img), dtype = np.float32)
img=img/255.0
x = Variable(np.asarray([X_test[0]]))
y = model(x)
prediction = y.data.argmax(axis=1)
在 y = model(x) 行之后出现错误: TypeError: call() 缺少 1 个必需的位置参数:'x'
TypeError: call() 缺少 1 个必需的位置参数:'x'
【问题讨论】:
-
请写下你是如何实例化
model的。 -
我正在使用 Jupyter Notebook。我刚刚完成了同一个笔记本中的模型的训练。模型的名称是 MyModel。
-
Neerajan,请添加完整代码以便更好地理解问题。
标签: python-3.x image-processing conv-neural-network predict chainer