# jzxocr **Repository Path**: zailushang/jzxocr ## Basic Information - **Project Name**: jzxocr - **Description**: ocr - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-02-26 - **Last Updated**: 2026-02-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README 3. ```bash # 📦 jzxocr — 端到端集装箱箱号识别系统 基于 **PaddleOCR v2.7** 实现的工业级集装箱 OCR 系统,支持: - ✅ **文本检测(Detection)**:定位整张集装箱图像中的箱号区域 - ✅ **文本识别(Recognition)**:识别标准11位箱号(如 `ABCD1234567`) - ✅ **端到端推理**:输入整图,输出箱号文本与位置 > **适用场景**:港口、物流、海关等需要自动识别集装箱编号的场合 > **字符集**:`0-9` + `A-Z`(共36字符,符合 ISO 6346 标准) --- ## 🗂 目录结构 jzxocr/ ├── configs/ # 训练配置文件 │ ├── det_container.yml # 检测模型配置(DB + MobileNetV3) │ └── rec_container.yml # 识别模型配置(CRNN + MobileNetV3,36字符) ├── dict/ │ └── container_dict.txt # 自定义字典(0-9 + A-Z) ├── data/ │ ├── det/ # 检测训练数据 │ │ ├── images/ # 整张集装箱图像 │ │ └── train_det.txt # 四点坐标标注(JSON格式) │ └── rec/ # 识别训练数据(可选) ├── models/ │ ├── pretrained/ # 预训练模型(需手动下载) │ │ └── ch_PP-OCRv3_det_distill_train/ # 中文检测训练模型(通用) │ └── output/ # 训练输出 │ ├── det_container/ # 检测模型 checkpoints │ └── rec_container/ # 识别模型 checkpoints ├── PaddleOCR/ # PaddleOCR v2.7 源码(git submodule) ├── tools → PaddleOCR/tools # 软链接 ├── ppocr → PaddleOCR/ppocr # 软链接 └── scripts/ ├── train_det.sh # 启动检测训练 ├── train_rec.sh # 启动识别训练 ├── verify_det_data.py # 验证检测标注格式 └── infer_end2end.py # 端到端推理示例 --- ## ⚙️ 环境依赖 - **Python**: 3.8–3.10 - **PaddlePaddle**: `==2.5.2` - **PaddleOCR**: `release/2.7` 分支 - **OS**: macOS / Linux(无需 GPU) ### 安装依赖 ```bash pip install -r requirements.txt requirements.txt 内容: paddlepaddle==2.5.2 opencv-python==4.8.1.78 PyYAML==6.0.1 lmdb==1.4.1 tqdm==4.66.1 shapely==2.0.1 scikit-image==0.21.0 📥 准备预训练模型(检测部分) 💡 识别模型从零训练(无需预训练),但检测建议使用官方模型加速收敛。 手动下载(推荐) 浏览器打开(需网络访问): https://paddleocr.bj.bcebos.com/PP-OCRv3/chinese/ch_PP-OCRv3_det_distill_train.tar 将下载的 .tar 文件放入项目: bash mv ~/Downloads/ch_PP-OCRv3_det_distill_train.tar models/pretrained/ tar -xf models/pretrained/ch_PP-OCRv3_det_distill_train.tar -C models/pretrained/ ✅ 验证:models/pretrained/ch_PP-OCRv3_det_distill_train/best_accuracy.pdparams 应存在(~100MB) 📝 数据准备 检测数据标注格式(data/det/train_det.txt) 每行格式为: json "image.jpg" [{"transcription": "ABCD1234567", "points": [[x1,y1],[x2,y2],[x3,y3],[x4,y4]]}] 示例: json "container_001.jpg" [{"transcription": "TGHU7894560", "points": [[120,80],[220,80],[220,130],[120,130]]}] 🔧 推荐使用 PPOCRLabel 工具进行标注。 识别数据(可选) 若单独训练识别模型,准备裁剪后的图像和标签: text data/rec/images/img1.jpg data/rec/rec_gt.txt → img1.jpg ABCD1234567 ▶️ 训练流程 1. 训练检测模型 bash ./scripts/train_det.sh 2. 训练识别模型(从零训练,36字符) bash ./scripts/train_rec.sh 💡 识别模型不依赖预训练权重,专为集装箱箱号优化。 🚀 端到端推理 运行示例脚本: bash python3 scripts/infer_end2end.py infer_end2end.py 内容: python from paddleocr import PaddleOCR ocr = PaddleOCR( use_angle_cls=False, lang="ch", det_model_dir="./models/output/det_container/best_accuracy", rec_model_dir="./models/output/rec_container/best_accuracy", rec_char_dict_path="./dict/container_dict.txt", rec_image_shape="3, 32, 320", rec_algorithm="CRNN", use_gpu=False ) result = ocr.ocr("your_container.jpg", cls=False) for line in result: box = line[0] text, conf = line[1] print(f"Box: {box} | Text: {text} (Conf: {conf:.2f})") 📌 注意事项 检测模型使用中文预训练(ch_PP-OCRv3_det_distill_train),但可检测任意语言文本区域。 识别模型字符集严格限定为 36 字符(0-9 + A-Z),避免 0/O、1/I 混淆。 若检测框过多或过少,调整推理时的 box_thresh(默认 0.6)。 建议检测数据 ≥ 200 张,识别数据 ≥ 500 张以获得稳定效果xxxxxxxxxx pip install -r requirements.txtpython3 scripts/verify_data.py./scripts/train.shbash ```