63 lines
995 B
Markdown
63 lines
995 B
Markdown
|
# Captcha Recognition
|
|||
|
|
|||
|
基于深度神经网络(DNN)的验证码识别
|
|||
|
|
|||
|
## 使用方法
|
|||
|
|
|||
|
1. 克隆项目到本地
|
|||
|
|
|||
|
```shell
|
|||
|
git clone https://git.taurusxin.com/taurusxin/captcha.git
|
|||
|
cd captcha
|
|||
|
```
|
|||
|
|
|||
|
2. 创建虚拟环境并安装依赖
|
|||
|
|
|||
|
```shell
|
|||
|
python -m venv .venv
|
|||
|
|
|||
|
# Windows
|
|||
|
.venv\Scripts\Activate.ps1
|
|||
|
|
|||
|
# Linux/MacOS
|
|||
|
source .venv/bin/activate
|
|||
|
|
|||
|
# 先安装 PyTorch GPU 版本,cuda 12.4
|
|||
|
pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
|
|||
|
|
|||
|
# 然后再安装其他依赖
|
|||
|
pip install -r requirements.txt
|
|||
|
```
|
|||
|
|
|||
|
3. 根据提示生成数据集,生成3次数据集,分别用于训练,用于测试,用于验证。
|
|||
|
|
|||
|
建议的数据集长度如下:
|
|||
|
|
|||
|
| 数据集 | 长度 |
|
|||
|
| -------- | ------- |
|
|||
|
| Train | 50000 |
|
|||
|
| Test | 1000 |
|
|||
|
| Predict | 30 |
|
|||
|
|
|||
|
```shell
|
|||
|
python captcha_gen.py
|
|||
|
```
|
|||
|
|
|||
|
4. 训练模型
|
|||
|
|
|||
|
```shell
|
|||
|
python train.py
|
|||
|
```
|
|||
|
|
|||
|
5. 测试模型
|
|||
|
|
|||
|
```shell
|
|||
|
python test.py
|
|||
|
```
|
|||
|
|
|||
|
6. 预测验证码
|
|||
|
|
|||
|
```shell
|
|||
|
python predict.py
|
|||
|
```
|