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

Error when checking : expected convolution2d_input_1 #4

Closed
hmert opened this issue Dec 29, 2016 · 4 comments
Closed

Error when checking : expected convolution2d_input_1 #4

hmert opened this issue Dec 29, 2016 · 4 comments

Comments

@hmert
Copy link

hmert commented Dec 29, 2016

I have following error.

➜  BossSensor git:(master) ✗ python camera_reader.py
Using TensorFlow backend.
Model Loaded.
face detected
Traceback (most recent call last):
  File "camera_reader.py", line 36, in <module>
    result = model.predict(image)
  File "/Users/huseyinmert/Desktop/tmp_code/BossSensor/boss_train.py", line 159, in predict
    result = self.model.predict_proba(image)
  File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 758, in predict_proba
    preds = self.predict(x, batch_size, verbose)
  File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 671, in predict
    return self.model.predict(x, batch_size=batch_size, verbose=verbose)
  File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 1161, in predict
    check_batch_dim=False)
  File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 108, in standardize_input_data
    str(array.shape))
Exception: Error when checking : expected convolution2d_input_1 to have shape (None, 64, 64, 3) but got array with shape (1, 3, 64, 64)
@Hironsan
Copy link
Owner

Hironsan commented Jan 2, 2017

what is your image_dim_ordering? th or tf?

https://keras.io/backend/

@tornadoyi
Copy link

/Users/Jason/ML/BossSensor/camera_reader.py
Using TensorFlow backend.
Model Loaded.
Traceback (most recent call last):
face detected
File "/Users/Jason/ML/BossSensor/camera_reader.py", line 36, in
result = model.predict(image)
File "/Users/Jason/ML/BossSensor/boss_train.py", line 159, in predict
result = self.model.predict_proba(image)
File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 758, in predict_proba
preds = self.predict(x, batch_size, verbose)
File "/usr/local/lib/python2.7/site-packages/keras/models.py", line 671, in predict
return self.model.predict(x, batch_size=batch_size, verbose=verbose)
File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 1161, in predict
check_batch_dim=False)
File "/usr/local/lib/python2.7/site-packages/keras/engine/training.py", line 108, in standardize_input_data
str(array.shape))
Exception: Error when checking : expected convolution2d_input_1 to have shape (None, 64, 64, 3) but got array with shape (1, 3, 64, 64)
Cleaned up camera.

I also have this error, how to resolve.

@bpgergo
Copy link

bpgergo commented Jan 3, 2017

I also got this error. my image_dim_ordering is "tf". could it be the reason that I have different sized images in the training folders?

@seeyourcell
Copy link

if use tensorflow,change model.predict to "
def predict(self, image):
if image.shape != (1, 3, IMAGE_SIZE, IMAGE_SIZE):
image = resize_with_pad(image)
if K.image_dim_ordering() == 'th':
image = image.reshape((1, 3, IMAGE_SIZE, IMAGE_SIZE))
else:
image = image.reshape((1, IMAGE_SIZE, IMAGE_SIZE ,3))
image = image.astype('float32')
image /= 255
result = self.model.predict_proba(image)
print(result)
result = self.model.predict_classes(image)

    return result[0]

"

then the "Exception: Error when checking : expected convolution2d_input_1 to have shape (None, 64, 64, 3) but got array with shape (1, 3, 64, 64)" disappear.

@hmert hmert closed this as completed Aug 25, 2021
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

5 participants