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

推荐订阅源

Forbes - Security
Forbes - Security
The Hacker News
The Hacker News
V
Vulnerabilities – Threatpost
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
P
Proofpoint News Feed
AWS News Blog
AWS News Blog
S
Securelist
S
Security @ Cisco Blogs
Cloudbric
Cloudbric
T
Troy Hunt's Blog
SecWiki News
SecWiki News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Security Latest
Security Latest
C
Cyber Attacks, Cyber Crime and Cyber Security
AI
AI
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Stack Overflow Blog
Stack Overflow Blog
I
Intezer
I
InfoQ
Attack and Defense Labs
Attack and Defense Labs
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recent Commits to openclaw:main
Recent Commits to openclaw:main
T
The Exploit Database - CXSecurity.com
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
News | PayPal Newsroom
云风的 BLOG
云风的 BLOG
S
Secure Thoughts
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
L
LINUX DO - 最新话题
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
D
Darknet – Hacking Tools, Hacker News & Cyber Security
A
About on SuperTechFans
Hacker News - Newest:
Hacker News - Newest: "LLM"
TaoSecurity Blog
TaoSecurity Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Webroot Blog
Webroot Blog
L
LangChain Blog
MyScale Blog
MyScale Blog
Recent Announcements
Recent Announcements
P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Engineering at Meta
Engineering at Meta
C
Cybersecurity and Infrastructure Security Agency CISA
Y
Y Combinator Blog
L
Lohrmann on Cybersecurity
B
Blog RSS Feed
The Last Watchdog
The Last Watchdog

高金的博客

人机协作逆向:用 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识别验证码/
版权声明:转载请注明出处!

推荐文章