Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multiple images for testing #18

Open
gaurav16gupta opened this issue Sep 3, 2017 · 0 comments
Open

Multiple images for testing #18

gaurav16gupta opened this issue Sep 3, 2017 · 0 comments

Comments

@gaurav16gupta
Copy link

Hi,
How can I pass multiple images as batch while testing?
I made these changes in use_dictnet.py line 44, just to check if I can provide multiple images.

def classify_image(self,img):
img = self._preprocess(img)
xtest = zeros((1,2,32,100))
xtest[0,0,:,:] = img
xtest[0,1,:,:] = img
z = self.model.predict_classes(xtest,verbose=0)[0]
return self.output_word[z][0]

I get the following error:

Traceback (most recent call last):
File "use_dictnet.py", line 62, in
print (cnn_model.classify_image(img))
File "use_dictnet.py", line 49, in classify_image
z = self.model.predict_classes(xtest,verbose=0)[0]
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/models.py", line 747, in predict_classes
proba = self.predict(X, batch_size=batch_size, verbose=verbose)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/models.py", line 716, in predict
return self._predict_loop(self._predict, X, batch_size, verbose)[0]
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/models.py", line 359, in _predict_loop
batch_outs = f(ins_batch)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/backend/theano_backend.py", line 473, in call
return self.function(*inputs)
File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 898, in call
storage_map=getattr(self.fn, 'storage_map', None))
File "/usr/local/lib/python2.7/dist-packages/theano/gof/link.py", line 325, in raise_with_op
reraise(exc_type, exc_value, exc_trace)
File "/usr/local/lib/python2.7/dist-packages/theano/compile/function_module.py", line 884, in call
self.fn() if output_subset is None else
ValueError: CorrMM images and kernel must have the same stack size

Apply node that caused the error: CorrMM{half, (1, 1), (1, 1)}(<TensorType(float32, 4D)>, Subtensor{::, ::, ::int64, ::int64}.0)
Toposort index: 15
Inputs types: [TensorType(float32, 4D), TensorType(float32, 4D)]
Inputs shapes: [(1, 2, 32, 100), (64, 1, 5, 5)]
Inputs strides: [(25600, 12800, 400, 4), (100, 100, -20, -4)]
Inputs values: ['not shown', 'not shown']
Outputs clients: [[Elemwise{Composite{(i0 * ((i1 + i2) + Abs((i1 + i2))))}}[(0, 1)](TensorConstant{(1, 1, 1, 1) of 0.5}, CorrMM{half, (1, 1), (1, 1)}.0, InplaceDimShuffle{x,0,x,x}.0)]]

Backtrace when the node is created(use Theano flag traceback.limit=N to make it longer):
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/convolutional.py", line 683, in get_output
X = self.get_input(train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/core.py", line 241, in get_input
previous_output = self.previous.get_output(train=train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/convolutional.py", line 310, in get_output
X = self.get_input(train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/core.py", line 241, in get_input
previous_output = self.previous.get_output(train=train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/convolutional.py", line 683, in get_output
X = self.get_input(train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/core.py", line 241, in get_input
previous_output = self.previous.get_output(train=train)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/layers/convolutional.py", line 315, in get_output
filter_shape=self.W_shape)
File "/home/gaurav/deeplearning/TEXT/reading-text-in-the-wild/DICT2/keras/backend/theano_backend.py", line 719, in conv2d
filter_shape=filter_shape)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant