# pvc **Repository Path**: jtyoui/pvc ## Basic Information - **Project Name**: pvc - **Description**: 这个一个基于TensorFlow做的一个验证码识别器 - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2018-01-25 - **Last Updated**: 2021-01-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # **pvc** [![tyoui](https://github.com/zhangwei0530/logo/blob/master/logo/photolog.png?raw=true)](http://www.tyoui.cn) [![](https://github.com/zhangwei0530/logo/blob/master/logo/logo.png?raw=true)](http://www.tyoui.cn) ## PVC是一个基于TensorFlow做的一个验证码识别器 [![](https://img.shields.io/badge/language-python-orange.svg)]() [![](https://img.shields.io/badge/Python-3.6-green.svg)]() [![](https://img.shields.io/badge/BlogWeb-Tyoui-bule.svg)](http://www.tyoui.cn) [![](https://img.shields.io/badge/Email-tyoui@tyoui.cn-red.svg)]() ## 使用的卷积神经网络流程图 ![](https://github.com/zhangwei0530/logo/blob/master/photo/cnn.png?raw=true) ## 卷积神经网络代码 ```python def crack_captcha_cnn(w_alpha=0.01, b_alpha=0.1): x = tf.reshape(X, shape=[-1, IMAGE_HEIGHT, IMAGE_WIDTH, 1]) w_c1 = tf.Variable(w_alpha * tf.random_normal([3, 3, 1, 32])) b_c1 = tf.Variable(b_alpha * tf.random_normal([32])) rel_1 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(x, w_c1, strides=[1, 1, 1, 1], padding='SAME'), b_c1)) pool_1 = tf.nn.max_pool(rel_1, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') con_1 = tf.nn.dropout(pool_1, keep_prob) w_c2 = tf.Variable(w_alpha * tf.random_normal([3, 3, 32, 64])) b_c2 = tf.Variable(b_alpha * tf.random_normal([64])) rel_2 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(con_1, w_c2, strides=[1, 1, 1, 1], padding='SAME'), b_c2)) pool_2 = tf.nn.max_pool(rel_2, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') con_2 = tf.nn.dropout(pool_2, keep_prob) w_c3 = tf.Variable(w_alpha * tf.random_normal([3, 3, 64, 64])) b_c3 = tf.Variable(b_alpha * tf.random_normal([64])) rel_3 = tf.nn.relu(tf.nn.bias_add(tf.nn.conv2d(con_2, w_c3, strides=[1, 1, 1, 1], padding='SAME'), b_c3)) pool_3 = tf.nn.max_pool(rel_3, ksize=[1, 2, 2, 1], strides=[1, 2, 2, 1], padding='SAME') con_3 = tf.nn.dropout(pool_3, keep_prob) w_d = tf.Variable(w_alpha * tf.random_normal([8 * 32 * 40, 1024])) b_d = tf.Variable(b_alpha * tf.random_normal([1024])) dense = tf.reshape(con_3, [-1, w_d.get_shape().as_list()[0]]) sigmoid = tf.nn.sigmoid(tf.add(tf.matmul(dense, w_d), b_d)) dense = tf.nn.dropout(sigmoid, keep_prob) w_out = tf.Variable(w_alpha * tf.random_normal([1024, MAX_CAPTCHA * CHAR_SET_LEN])) b_out = tf.Variable(b_alpha * tf.random_normal([MAX_CAPTCHA * CHAR_SET_LEN])) out = tf.add(tf.matmul(dense, w_out), b_out) return out ``` ## 先执行train.py,之后会有训练模型model文件夹,输出是每训练10次打印一次精度 0 精度: 0.0875 10 精度: 0.11 当打印到百分之90时,将自动停止。训练精度设置在 ```python if acc > 0.900: saver.save(sess, "./model/captcha.model", global_step=0) break ``` ## 测试文件。在test.py 测试时将自动生成一张照片。输出正确值与测试值 ## 验证码文件值 char_set = number + alphabet + ALPHABET