def recognize_captcha(self):
    (label, captcha_array) = self.gen_captcha_text_image(random.choice(self.img_list))
    f = plt.figure()
    ax = f.add_subplot(111)
    ax.text(0.1, 0.9, ('origin:' + label), ha='center', va='center', transform=ax.transAxes)
    plt.imshow(captcha_array)
    image = self.convert2gray(captcha_array)
    image = (image.flatten() / 255)
    y_predict = self.model()
    saver = tf.train.Saver()
    with tf.Session() as sess:
        saver.restore(sess, self.model_save_dir)
        predict = tf.argmax(tf.reshape(y_predict, [(- 1), self.max_captcha, self.char_set_len]), 2)
        text_list = sess.run(predict, feed_dict={self.X: [image], self.keep_prob: 1.0})
        predict_text = text_list[0].tolist()
    print('正确: {}  预测: {}'.format(label, predict_text))
    p_text = ''
    for p in predict_text:
        p_text += str(self.char_set[p])
    print(p_text)
    plt.text(20, 1, 'predict:{}'.format(p_text))
    plt.show()
def recognize_captcha(self):
    (label, captcha_array) = self.gen_captcha_text_image(random.choice(self.img_list))
    f = plt.figure()
    ax = f.add_subplot(111)
    ax.text(0.1, 0.9, ('origin:' + label), ha='center', va='center', transform=ax.transAxes)
    plt.imshow(captcha_array)
    image = self.convert2gray(captcha_array)
    image = (image.flatten() / 255)
    y_predict = self.model()
    saver = tf.train.Saver()
    with tf.Session() as sess:
        saver.restore(sess, self.model_save_dir)
        predict = tf.argmax(tf.reshape(y_predict, [(- 1), self.max_captcha, self.char_set_len]), 2)
        text_list = sess.run(predict, feed_dict={self.X: [image], self.keep_prob: 1.0})
        predict_text = text_list[0].tolist()
    print('正确: {}  预测: {}'.format(label, predict_text))
    p_text = 
    for p in predict_text:
        p_text += str(self.char_set[p])
    print(p_text)
    plt.text(20, 1, 'predict:{}'.format(p_text))
    plt.show()