tesseract5 笔记 新字体训练

windows 安装git,之后在 git bash中运行
clone
https://github.com/tesseract-ocr/tesstrain

在文件夹内建一个data文件夹
再建一个new_tha-ground-truth文件夹
里面放入生成的.tif,.box,.gt.txt,文件
文件名要相同
.tif:图片
.box:图片对应的坐标
.gt.txt: 图片里对应的文字
data下建一个new_tha文件夹
里面放的文件待补

命令

make training MODEL_NAME=new_tha START_MODEL=tha

warning:

Setting unichar properties
Setting script properties
Warning: properties incomplete for index 18 = ึ
Warning: properties incomplete for index 20 = ุ
Warning: properties incomplete for index 25 = ็
Warning: properties incomplete for index 27 = ิ
Warning: properties incomplete for index 29 = ั
Warning: properties incomplete for index 44 = ี
Warning: properties incomplete for index 49 = ้
Warning: properties incomplete for index 51 = ์
Warning: properties incomplete for index 53 = ื
Warning: properties incomplete for index 55 = ู
Warning: properties incomplete for index 59 = ่
Warning: properties incomplete for index 69 = ๊
Warning: properties incomplete for index 71 = ํ
Warning: properties incomplete for index 74 = ๋
Warning: properties incomplete for index 119 = ~

说明unicharset里,某些字符的属性未完全设置。
找到对应字符的box文件
就改box里对应的字符

解决办法

1.首先,提取字符集:
制作 generate_unicharset.sh 文件在根目录

#!/bin/bash

# Define the directory containing the .box files
BOX_DIR="data/new_tha-ground-truth"
MERGED_BOX="all_boxes.box"
UNICHARSET_OUTPUT="unicharset"
NEW_UNICHARSET_OUTPUT="new_unicharset"
LANG_CONFIG="lang.config"

# Merge all .box files into one
find "$BOX_DIR" -name '*.box' -exec cat {} + > "$MERGED_BOX"

# Extract the unicharset from the merged .box file
/d/program/Tesseract-OCR/unicharset_extractor "$MERGED_BOX"

在git bash里执行

chmod +x generate_unicharset.sh
./generate_unicharset.sh

将生成的unicharset 复制到 另一个 项目 langdata_lstm\tha下
在 git bash 里执行

$ set_unicharset_properties -U unicharset -O new_unicharset -X tha.config --script_dir ..

-script_dir … :是上一层目录含有Thai.unicharset,Latin.unicharset 两个文件
会生成
new_unicharset文件重命名unicharset放回 tesstrain\data\new_tha里

  • 6
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
Tesseract是一款开源的OCR(Optical Character Recognition)引擎,主要用于文字识别任务。它支持多种语言,并且可以通过训练来提高文字识别的准确度。 要训练Tesseract来识别多张图片,我们首先需要准备一些包含文字的图片样本。这些样本应该是具有代表性和多样性的,覆盖不同字体、字号、颜色以及背景等情况。可以从不同来源收集这些图片,例如从互联网或自己创建。 一旦准备好样本图片,我们需要将它们标记为训练数据。这意味着我们需要告诉Tesseract每张图片中的文字是什么,并创建一个对应的文本文件。这可以通过使用Tesseract训练工具来完成。训练工具将会通过匹配样本图片和文本文件来生成模型文件,该模型文件将用于训练Tesseract识别文字。 在训练过程中,我们可以指定训练的参数,例如迭代次数、学习率等。这些参数将影响识别准确度和速度。通常情况下,迭代次数越多,训练的准确度越高,但也会增加训练时间。 训练完毕后,我们可以将生成的模型文件应用到Tesseract上。这样,Tesseract将能够更好地识别多张图片中的文字。 需要注意的是,训练Tesseract需要一定的技术知识和对文字识别原理的理解。同时,训练过程也需要较长的时间和大量的计算资源。因此,除非必要,一般用户可能更倾向于使用已经训练好的模型来进行文字识别。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值