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

实际项目中的验证码图片如何放入接口识别呢? #17

Open
mengguiyouziyi opened this issue Nov 29, 2017 · 3 comments
Open

Comments

@mengguiyouziyi
Copy link

Uploading image.png…
if name == 'main':
# text, image = gen_captcha_text_and_image()
text = '1dxz'
captcha = 'y.jpg'
image = Image.open(captcha)
# image.show()
image = np.array(image)
image = convert2gray(image)
image = image.flatten() / 255
predict_text = crack_captcha(image)
print("正确: {} 预测: {}".format(text, predict_text))

# train_crack_captcha_cnn()
# text, image = gen_captcha_text_and_image()
# image = convert2gray(image)  # 生成一张新图
# image = image.flatten() / 255  # 将图片一维化
# predict_text = crack_captcha(image)  # 导入模型识别
# print("正确: {}  预测: {}".format(text, predict_text))

报错:
验证码图像channel: (36, 70, 3)
验证码文本最长字符数 4
2017-11-28 22:35:53.116468: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
Traceback (most recent call last):
File "/Users/menggui/Desktop/project/zhuanli_spider/cnipr/other_operate/test_2/tensorflow_cnn.py", line 229, in
predict_text = crack_captcha(image)
File "/Users/menggui/Desktop/project/zhuanli_spider/cnipr/other_operate/test_2/tensorflow_cnn.py", line 209, in crack_captcha
text_list = sess.run(predict, feed_dict={X: [captcha_image], keep_prob: 1})
File "/Users/menggui/.pyenv/versions/env_comm_Ana3-4.3.0/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 889, in run
run_metadata_ptr)
File "/Users/menggui/.pyenv/versions/env_comm_Ana3-4.3.0/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1096, in _run
% (np_val.shape, subfeed_t.name, str(subfeed_t.get_shape())))
ValueError: Cannot feed value of shape (1, 36, 70) for Tensor 'Placeholder:0', which has shape '(?, 9600)'

@luyishisi
Copy link
Owner

luyishisi commented Mar 29, 2018

这是说明你给的验证码图片和训练的以及模型本身定义的图片大小不符合,建议是1:可以resize你要投入的图片,2:用你当前的图片重新打码训练模型

@limbo-envoy
Copy link

limbo-envoy commented Jul 13, 2018

InvalidArgumentError (see above for traceback): Incompatible shapes: [38,378] vs. [64,378]
[[Node: logistic_loss/mul = Mul[T=DT_FLOAT, _device="/job:localhost/replica:0/task:0/device:CPU:0"](Add_1, _arg_Placeholder_1_0_1)]]
我想用我当前图片进行验证码训练, 但是出现了这个错误无法训练,您能看看这个属于什么问题吗?我在网上搜了下,但是看得没有头绪

@limbo-envoy
Copy link

哦, 重新更改图片尺寸没有报错。

@leng-yue leng-yue closed this as completed Oct 1, 2018
@leng-yue leng-yue reopened this Oct 1, 2018
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
@luyishisi @mengguiyouziyi @leng-yue @limbo-envoy and others