Files
CaptchBreaker/training/train_3d_text.py
Hua f5be7671bc Expand 3D captcha into three subtypes: 3d_text, 3d_rotate, 3d_slider
Split the single "3d" captcha type into three independent expert models:
- 3d_text: 3D perspective text OCR (renamed from old "3d", CTC-based ThreeDCNN)
- 3d_rotate: rotation angle regression (new RegressionCNN, circular loss)
- 3d_slider: slider offset regression (new RegressionCNN, SmoothL1 loss)

CAPTCHA_TYPES expanded from 3 to 5 classes. Classifier samples updated
to 50000 (10000 per class). New generators, model, dataset, training
utilities, and full pipeline/export/CLI support for all subtypes.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-11 13:55:53 +08:00

41 lines
1018 B
Python
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
"""
训练 3D 立体文字验证码识别模型 (ThreeDCNN)
用法: python -m training.train_3d_text
"""
from config import (
THREED_CHARS,
IMAGE_SIZE,
SYNTHETIC_3D_TEXT_DIR,
REAL_3D_TEXT_DIR,
)
from generators.threed_gen import ThreeDCaptchaGenerator
from models.threed_cnn import ThreeDCNN
from training.train_utils import train_ctc_model
def main():
img_h, img_w = IMAGE_SIZE["3d_text"]
model = ThreeDCNN(chars=THREED_CHARS, img_h=img_h, img_w=img_w)
print("=" * 60)
print("训练 3D 立体文字验证码识别模型 (ThreeDCNN)")
print(f" 字符集: {THREED_CHARS} ({len(THREED_CHARS)} 字符)")
print(f" 输入尺寸: {img_h}×{img_w}")
print("=" * 60)
train_ctc_model(
model_name="threed_text",
model=model,
chars=THREED_CHARS,
synthetic_dir=SYNTHETIC_3D_TEXT_DIR,
real_dir=REAL_3D_TEXT_DIR,
generator_cls=ThreeDCaptchaGenerator,
config_key="3d_text",
)
if __name__ == "__main__":
main()