Initialize repository

This commit is contained in:
Hua
2026-03-10 18:47:29 +08:00
commit 760b80ee5e
32 changed files with 4343 additions and 0 deletions

40
training/train_3d.py Normal file
View File

@@ -0,0 +1,40 @@
"""
训练 3D 立体验证码识别模型 (ThreeDCNN)
用法: python -m training.train_3d
"""
from config import (
THREED_CHARS,
IMAGE_SIZE,
SYNTHETIC_3D_DIR,
REAL_3D_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"]
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",
model=model,
chars=THREED_CHARS,
synthetic_dir=SYNTHETIC_3D_DIR,
real_dir=REAL_3D_DIR,
generator_cls=ThreeDCaptchaGenerator,
config_key="threed",
)
if __name__ == "__main__":
main()