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

Input to reshape is a tensor with 10 values, but the requested shape requires a multiple of 40 #165

Open
85757 opened this issue Sep 14, 2020 · 0 comments

Comments

@85757
Copy link

85757 commented Sep 14, 2020

运行webserver_recognize_api.py后,向接口post图片文件时,报以下错误:

Traceback (most recent call last):
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1365, in _do_call
return fn(*args)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1350, in _run_fn
target_list, run_metadata)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1443, in _call_tf_sessionrun
run_metadata)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 10 values, but the requested shape requires a multiple of 40
[[{{node Reshape_2}}]]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 2464, in call
return self.wsgi_app(environ, start_response)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 2450, in wsgi_app
response = self.handle_exception(e)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 1867, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 2447, in wsgi_app
response = self.full_dispatch_request()
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 1952, in full_dispatch_request
rv = self.handle_user_exception(e)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 1821, in handle_user_exception
reraise(exc_type, exc_value, tb)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/_compat.py", line 39, in reraise
raise value
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 1950, in full_dispatch_request
rv = self.dispatch_request()
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/flask/app.py", line 1936, in dispatch_request
return self.view_functionsrule.endpoint
File "/Users/mac/Desktop/hello/webserver_recognize_api.py", line 68, in up_image
value = R.rec_image(img)
File "/Users/mac/Desktop/hello/cnnlib/recognition_object.py", line 51, in rec_image
text_list = sess.run(self.predict, feed_dict={self.X: [test_image], self.keep_prob: 1.})
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 958, in run
run_metadata_ptr)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1181, in _run
feed_dict_tensor, options, run_metadata)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1359, in _do_run
run_metadata)
File "/Users/mac/Desktop/hello/venv/lib/python3.7/site-packages/tensorflow/python/client/session.py", line 1384, in _do_call
raise type(e)(node_def, op, message)
tensorflow.python.framework.errors_impl.InvalidArgumentError: Input to reshape is a tensor with 10 values, but the requested shape requires a multiple of 40
[[node Reshape_2 (defined at /cnnlib/recognition_object.py:34) ]]

Errors may have originated from an input operation.
Input Source operations connected to node Reshape_2:
y_prediction/Add (defined at /cnnlib/network.py:103)

Original stack trace for 'Reshape_2':
File "/webserver_recognize_api.py", line 45, in
R = Recognizer(image_height, image_width, max_captcha, char_set, model_save_dir)
File "/cnnlib/recognition_object.py", line 34, in init
self.predict = tf.argmax(input=tf.reshape(self.y_predict, [-1, self.max_captcha, self.char_set_len]), axis=2)
File "/venv/lib/python3.7/site-packages/tensorflow/python/util/dispatch.py", line 201, in wrapper
return target(*args, **kwargs)
File "/venv/lib/python3.7/site-packages/tensorflow/python/ops/array_ops.py", line 195, in reshape
result = gen_array_ops.reshape(tensor, shape, name)
File "/venv/lib/python3.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 8234, in reshape
"Reshape", tensor=tensor, shape=shape, name=name)
File "/venv/lib/python3.7/site-packages/tensorflow/python/framework/op_def_library.py", line 744, in _apply_op_helper
attrs=attr_protos, op_def=op_def)
File "/venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 3485, in _create_op_internal
op_def=op_def)
File "/venv/lib/python3.7/site-packages/tensorflow/python/framework/ops.py", line 1949, in init
self._traceback = tf_stack.extract_stack()

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