TensorFlow识别复杂验证码以及搭建生产环境(4)—— 读取测试集
2018-01-06 12:19
337 查看
0x00 前言
本篇博文的代码主要修改自以前的一篇文章: Tensorflow应用之简单验证码识别
0x01 test_check_code.py
这个python 文件主要是实现了顺序读取训练集里面的内容并将其封装成一个函数供神经网络测试使用。
其中的 root_dir 参数要根据具体的训练文件的位置进行修改。
(代码如下)import numpy as np from PIL import Image import os root_dir = "d:\\jwxt\\test" img_list = [] def gen_list(): for parent, dirnames, filenames in os.walk(root_dir): # 三个参数:分别返回1.父目录 2.所有文件夹名字(不含路径) 3.所有文件名字 for filename in filenames: # 输出文件信息 img_list.append(filename.replace(".jpg", "")) # print("parent is:" + parent) # print("filename is:" + filename) # print("the full name of the file is:" + os.path.join(parent, filename)) # 输出文件路径信息 return img_list img_list = gen_list() def get_test_captcha_text_and_image(i=None): img = img_list[i] captcha_image = Image.open(root_dir + "\\" + img + ".jpg") # captcha_image = captcha_image.resize((160, 60)) captcha_image = np.array(captcha_image) return img, captcha_image def get_test_sets_length(): return len(img_list)
0x02 相关的代码说明
get_test_captcha_text_and_image 函数包含一个参数(i)
表示读取这个文件夹的第i张文件相关文章推荐
- TensorFlow识别复杂验证码以及搭建生产环境(6)—— 训练与测试
- TensorFlow识别复杂验证码以及搭建生产环境(3)—— 随机读取训练集
- TensorFlow识别复杂验证码以及搭建生产环境(5)—— 设计神经网络
- TensorFlow识别复杂验证码以及搭建生产环境(8)—— 基于Python的调用
- TensorFlow识别复杂验证码以及搭建生产环境(2)—— 搭建训练环境
- TensorFlow识别复杂验证码以及搭建生产环境(7)—— 使用TensorFlow-Serving部署生产环境
- TensorFlow识别复杂验证码以及搭建生产环境(1)—— 收集训练集
- TensorFlow识别复杂验证码以及搭建生产环境(9)—— 基于Java的调用
- Hibernate环境搭建以及测试(maven)
- centos svn服务器搭建 多账号多项目不同权限配置 hook配置 项目提交自动同步 测试及生产环境配置
- (jenkins)hudson平台搭建android项目持续化集成以及基于NativeDriver的自动化测试环境
- Hadoop-2.6.2 HA + Federation 生产环境集群搭建实例以及源码编译案例分享
- kafka本地环境的搭建,以及本地java测试的调用
- Windows下TensorFlow环境搭建(无GPU)以及windows及linux环境下永久修改pip镜像源的方法
- python图片(验证码)识别环境搭建(基于centos7)
- MFC环境下搭建OpenGL框架并进行数据文件读取以及模型绘制的注意事项
- 手把手教你搭建智能合约测试环境、开发、编译、部署以及如何通过JS调用合约方法
- MPI并行计算环境搭建以及集群测试
- Darknet yolo 环境搭建以及训练测试自己的数据集
- 阿里云Ubuntu系统从0搭建LAMP(Apache+MySQL+PHP)以及服务器生产环境常用配置