Views
No views yet
| 文件 | 变体 | 参数量 | 文件大小 | 验证集准确率 | 推荐场景 |
|---|---|---|---|---|---|
small/final_model.pth | small | ~96K | 390 KB | 99.96% | 通用部署(推荐) |
full/final_model.pth | full | ~196K | 780 KB | 99.97% | 追求极致精度 |
nano/final_model.pth | nano | ~21K | 94 KB | 95.49% | 极致压缩 / 嵌入式 |
distill-nano/final_model.pth | nano (distilled) | ~21K | 94 KB | — | 蒸馏实验产物 |
推荐选择small:390KB 即可达到 99.96% 准确率,性价比最高。
| 样本 | 标签 |
|---|---|
![]() | 9800 |
![]() | 9350 |
Input (3, 34, 90)
→ [Conv3×3 + BN + ReLU + MaxPool] × 3 (空间降采样)
→ [Conv3×3 + BN + ReLU] × N (特征提取)
→ AdaptiveAvgPool2d(1, 4) (压缩为 4 列,对应 4 个数字位置)
→ 4 × Linear(C, 10) (每个位置独立 10 分类)
Output: (B, 4, 10) logits1import torch
2from torchvision import transforms
3from PIL import Image
4
5# 1. Define model (copy from src/model.py or install the package)
6from model import build_model
7
8# 2. Load
9model = build_model('small')
10model.load_state_dict(torch.load('small/final_model.pth', map_location='cpu'))
11model.eval()
12
13# 3. Preprocess
14transform = transforms.Compose([
15 transforms.Resize((34, 90)),
16 transforms.ToTensor(),
17 transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
18])
19
20img = Image.open('captcha.png').convert('RGB')
21x = transform(img).unsqueeze(0) # (1, 3, 34, 90)
22
23# 4. Predict
24with torch.no_grad():
25 logits = model(x) # (1, 4, 10)
26 digits = logits.argmax(dim=2) # (1, 4)
27 result = ''.join(str(d.item()) for d in digits[0])
28
29print(result) # e.g. "3807"