惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Help Net Security
Help Net Security
U
Unit 42
T
Tailwind CSS Blog
Y
Y Combinator Blog
阮一峰的网络日志
阮一峰的网络日志
博客园_首页
云风的 BLOG
云风的 BLOG
博客园 - Franky
D
DataBreaches.Net
Last Week in AI
Last Week in AI
人人都是产品经理
人人都是产品经理
Cisco Talos Blog
Cisco Talos Blog
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Blog — PlanetScale
Blog — PlanetScale
Know Your Adversary
Know Your Adversary
宝玉的分享
宝玉的分享
V
Visual Studio Blog
AWS News Blog
AWS News Blog
NISL@THU
NISL@THU
I
Intezer
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
P
Privacy International News Feed
T
Tor Project blog
S
Securelist
Microsoft Security Blog
Microsoft Security Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Recorded Future
Recorded Future
C
Cisco Blogs
P
Palo Alto Networks Blog
Hacker News: Ask HN
Hacker News: Ask HN
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Commits to openclaw:main
Recent Commits to openclaw:main
月光博客
月光博客
T
Threat Research - Cisco Blogs
N
News and Events Feed by Topic
AI
AI
Cyberwarzone
Cyberwarzone
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
MongoDB | Blog
MongoDB | Blog
Microsoft Azure Blog
Microsoft Azure Blog
Scott Helme
Scott Helme
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Martin Fowler
Martin Fowler
量子位
L
LINUX DO - 热门话题
H
Heimdal Security Blog
GbyAI
GbyAI
P
Privacy & Cybersecurity Law Blog
博客园 - 【当耐特】

高金的博客

人机协作逆向:用 AI + Frida 打通微信 4.1.8 macOS 数据库密钥提取 情绪价值与求真:如何平衡与应对? friend_tech 第一笔交易只能买 1 个key? friend_tech 套利到底有多卷 无公网ip,无服务器实现内网穿透 植物挖矿 浏览器环境检测 加密、编码相关知识汇总 POW与反爬虫 appium 安卓无法点击搜索框解决办法 知乎直播弹幕抓取与解析 知乎直播套利分析 1000刀+的羊毛在等你 如何创建一个完全匿名的EOS、ETH账号 如何通过技术手段证明"我"没有去过武汉 XUNTA 季度报告 玩游戏不如CX,JUSTGAME邀请分析(内附元数据) 如何在conflux上部署合约 程序员找对象聚合平台-xunta.today EOS 1.8 bidname的漏洞分析
使用tensorflow识别验证码
Gao JIn · 2020-05-12 · via 高金的博客

tensorflow-cnn-captcha-server

背景

大家都知道机器学习对识别验证码很好用

但是对于一个爬虫工程师来说,去学习 机器学习相关知识可能成本太高了.(当然有空的话,还是要好好学的)

本篇 是 以实用为主,让你不需要了解任何机器学习的知识,只需要按照配置把图片放好…

就可以解决 验证码问题.

前提

需要有标记好的验证码图片

没有的话,假如你现在是接的商用的打码服务,可以把验证通过的图片存下来。

或者自己手工标记一批…(懒的话 对接打码服务也是可以的.)

爬虫来训练这个模型,自己识别验证码收益是非常高的。

假设训练1天后,有95%的准确率来,你就接入自己的服务,并且后续一直把通过的图片保存下来

这样的话…你的样本是越来越多…识别率也就越来越高

环境

python版本: 3.7

系统: mac ubuntu 都测试过.

安装依赖

pip install -r requirements.txt

opencv 安装

conda install -c conda-forge opencv

参考 https://anaconda.org/conda-forge/opencv

使用

更改 train/config.py 里面的配置

DATA_DIR

验证码图片路径(注意,默认验证码图片命名规则是 验证码_xxx.jpg)

也就是说是以_分割的, 需要自定义可以修改 parse_filepath这个方法

H, W, C

图片的高、宽、多少层

理论上验证码的图片大小都是一样的…如果有的不一样,就填成自己想要统一成的大小

str_charts

验证码里的所有字符,或者说验证码由哪些组成(比如全是数字验证码、数字+大小写的验证码)

D

验证码的长度 (4位验证码,6位验证码等等

accuracy_rate

到多少准确度以后就停止训练

model_file_name

训练完后的model文件(api需要用到)

image_type

图片后缀 比如jpg、png

开始训练

python train/cnn.py

使用api

识别验证码

1
2
3
4
5
6
def test1():
"提交验证码图片文件"
imname = "11216h_3579db1e15a3541dc5b696f6093e1cc4.png"
files = {"file": open(imname, "rb")}
r = requests.post("http://127.0.0.1:5000/upload", files=files)
print(r.json())

反馈验证结果

1
2
3
4
5
6
7
8
def test2():
"提交返回结果"
reqid = "7537ea4b-b26d-4263-a628-6b02c2d37add"
status = 1
r = requests.get(
"http://127.0.0.1:5000/upload", params={"reqid": reqid, "status": status}
)
print(r.json())

项目地址

https://github.com/jin10086/tensorflow-cnn-captcha-server

实例截图

参考

https://github.com/JackonYang/captcha-tensorflow


本文作者:高金
本文地址https://igaojin.me/2020/05/12/使用tensorflow识别验证码/
版权声明:转载请注明出处!

推荐文章