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_math.py Normal file
View File

@@ -0,0 +1,40 @@
"""
训练算式识别模型 (LiteCRNN - math 模式)
用法: python -m training.train_math
"""
from config import (
MATH_CHARS,
IMAGE_SIZE,
SYNTHETIC_MATH_DIR,
REAL_MATH_DIR,
)
from generators.math_gen import MathCaptchaGenerator
from models.lite_crnn import LiteCRNN
from training.train_utils import train_ctc_model
def main():
img_h, img_w = IMAGE_SIZE["math"]
model = LiteCRNN(chars=MATH_CHARS, img_h=img_h, img_w=img_w)
print("=" * 60)
print("训练算式识别模型 (LiteCRNN - math)")
print(f" 字符集: {MATH_CHARS} ({len(MATH_CHARS)} 字符)")
print(f" 输入尺寸: {img_h}×{img_w}")
print("=" * 60)
train_ctc_model(
model_name="math",
model=model,
chars=MATH_CHARS,
synthetic_dir=SYNTHETIC_MATH_DIR,
real_dir=REAL_MATH_DIR,
generator_cls=MathCaptchaGenerator,
config_key="math",
)
if __name__ == "__main__":
main()