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

Author: mengguiyouziyiCreated Nov 29, 2017Updated Oct 1, 2018

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)'

Source: luyishisi/Anti-Anti-Spider