-1

This a classification process for blood cells. I have 2 classes: Mononuclear and Polynuclear. The training is done. X_test is the image array and y_test is the label array. I am trying to predict the label of a single input image.

I have changed the label array into dtype int and have flattened it and image array in float32 as I have done with the training image and label. Do I need to make a test dataset as I have made a train dataset using DatasetMixin? And how do I get the desired result. I am aiming for a single image prediction only.

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)

After the line y = model(x) I get the error: TypeError: call() missing 1 required positional argument: 'x'

TypeError: call() missing 1 required positional argument: 'x'

TulakHord
  • 422
  • 7
  • 15

1 Answers1

1

You might have missed labels, which were assumed to be fed to the model during training.

Yuki Hashimoto
  • 1,013
  • 7
  • 19
  • Labels are y_train and y_test for training and test dataset respectively. y_train was converted to int and then flattened before putting it into dataset_train along with X_train using DatasetMixin. This dataset_train was then split into training and validation(20%) part and fed into the model using train_iter. – TulakHord Jan 15 '19 at 10:15
  • x = Variable(np.asarray([X_test[0]])) ... It seems you arbitrary select image part only. If you want "good" answer, you have to propose the minimal code to reproduce. – Yuki Hashimoto Jan 15 '19 at 11:07