{"id":22354741,"url":"https://github.com/pprp/captcha_identify.pytorch","last_synced_at":"2025-10-25T12:19:16.261Z","repository":{"id":61954290,"uuid":"216292412","full_name":"pprp/captcha_identify.pytorch","owner":"pprp","description":"基于torch进行验证码识别,识别率达94%","archived":false,"fork":false,"pushed_at":"2023-06-23T03:03:25.000Z","size":307378,"stargazers_count":116,"open_issues_count":10,"forks_count":26,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-06T05:31:57.190Z","etag":null,"topics":["captcha","cnn","deep-learning","pytorch"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pprp.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-10-20T01:35:49.000Z","updated_at":"2025-03-26T14:38:25.000Z","dependencies_parsed_at":"2022-10-24T04:45:14.607Z","dependency_job_id":null,"html_url":"https://github.com/pprp/captcha_identify.pytorch","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pprp/captcha_identify.pytorch","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fcaptcha_identify.pytorch","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fcaptcha_identify.pytorch/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fcaptcha_identify.pytorch/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fcaptcha_identify.pytorch/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pprp","download_url":"https://codeload.github.com/pprp/captcha_identify.pytorch/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pprp%2Fcaptcha_identify.pytorch/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267845678,"owners_count":24153774,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["captcha","cnn","deep-learning","pytorch"],"created_at":"2024-12-04T13:15:01.494Z","updated_at":"2025-10-25T12:19:16.196Z","avatar_url":"https://github.com/pprp.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 深度学习识别验证码\n\n基于: https://github.com/dee1024/pytorch-captcha-recognition 进行修改\n\n本项目致力于使用神经网络来识别各种验证码。\n\n在这个库的基础上，进行了改动，添加了很多trick来增强识别效果，如attention机制，dual pooling, ibn模块，bnneck,center loss等。\n\n链接为：https://github.com/pprp/captcha.Pytorch\n\n改动\n===\n- 添加了更多torchvision中支持的模型\n- 改了一下文件的名称\n- 支持了GPU，当然cpu也可以\n- 添加了以下功能：训练完成一个epoch之后进行测试，（需要保证test和train中的模型一致）\n- 添加了以下功能：将每次得到的测试结果写入results.txt文件，运行torch_util.py得到results.png可视化准确率。\n- RES152为基础网络进行训练，混合数字和大写字符只能达到94%，还达不到原作者的识别率，希望得到赐教\n\n特性\n===\n- __端到端，不需要做更多的图片预处理（比如图片字符切割、图片尺寸归一化、图片字符标记、字符图片特征提取）__\n- __验证码包括数字、大写字母、小写__\n- __采用自己生成的验证码来作为神经网络的训练集合、测试集合、预测集合__\n- __纯四位数字，验证码识别率高达 99.9999 %__\n- __四位数字 + 大写字符，验证码识别率约 96 %__\n- __深度学习框架pytorch + 验证码生成器ImageCaptcha__\n\n\n原理\n===\n\n- __训练集合生成__\n\n    使用常用的 Python 验证码生成库 ImageCaptcha，生成 10w 个验证码，并且都自动标记好;\n    如果需要识别其他的验证码也同样的道理，寻找对应的验证码生成算法自动生成已经标记好的训练集合或者手动对标记，需要上万级别的数量，纯手工需要一定的时间，再或者可以借助一些网络的打码平台进行标记\n\n- __训练卷积神经网络__\n    构建一个多层的卷积网络，进行多标签分类模型的训练\n    标记的每个字符都做 one-hot 编码\n    批量输入图片集合和标记数据，大概15个Epoch后，准确率已经达到 96% 以上\n\n\n验证码识别率展示\n========\n![](https://raw.githubusercontent.com/dee1024/pytorch-captcha-recognition/master/docs/number.png)\n\n快速开始\n====\n- __步骤一：10分钟环境安装__\n\n    Python3.6+ 、ImageCaptcha库(pip install captcha)、 Pytorch(参考官网http://pytorch.org)\n\n\n- __步骤二：生成验证码__\n    ```bash\n    python captchaGenerator.py\n    ```\n    执行以上命令，会在目录 dataset/train/ 下生成多张验证码图片，图片已经标注好，数量可以是 1w、5w、10w，通过 captchaGenerator.py 内的 count 参数设定\n    \n- __步骤三：训练模型__\n    ```bash\n    python train.py\n    ```\n    使用步骤一生成的验证码图集合用CNN模型（在 models 中定义）进行训练，训练完成会生成文件保存在weights文件夹中，最好的结果保存为`cnn_best.pt`\n\n- __步骤四：测试模型__\n    ```bash\n    python test.py\n    ```\n    可以在控制台，看到模型的准确率（如 95%） ，如果准确率较低，回到步骤一，生成更多的图片集合再次训练\n\n- __步骤五：使用模型做预测__\n    ```bash\n    python predict.py\n    ```\n    可以在控制台，看到预测输出的结果\n    \n\n可视化\n===\n\n![results_res101](assets/results_res101.png)\n\n贡献\n===\n\n我们期待你的 pull requests !\n\n有问题欢迎提出issue\n\n作者\n===\n* __Dee Qiu__ \u003ccoolcooldee@gmail.com\u003e\n* 补充：__pprp__ \u003c1115957667@qq.com\u003e\n\n\n声明\n===\n本项目仅用于交流学习\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprp%2Fcaptcha_identify.pytorch","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpprp%2Fcaptcha_identify.pytorch","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpprp%2Fcaptcha_identify.pytorch/lists"}