69 lines
1.0 KiB
Markdown
69 lines
1.0 KiB
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次数据集,分别用于训练,用于测试,用于验证。
|
||
|
||
```shell
|
||
python captcha_gen.py
|
||
```
|
||
|
||
建议的数据集长度如下:
|
||
|
||
| 数据集 | 长度 |
|
||
| -------- | ------- |
|
||
| Train | 50000 |
|
||
| Test | 1000 |
|
||
| Predict | 30 |
|
||
|
||
4. 训练模型
|
||
|
||
```shell
|
||
python train.py
|
||
```
|
||
|
||
5. 测试模型
|
||
|
||
```shell
|
||
python test.py
|
||
```
|
||
|
||
6. 预测验证码
|
||
|
||
```shell
|
||
python predict.py
|
||
```
|
||
|
||
7. 输出 onnx 模型
|
||
|
||
```shell
|
||
python export_onnx.py
|
||
```
|