0

在最终成功安装它的依赖项之后,我想训练 OpenALPR 的神经网络。我现在需要的只是执行train.py,根据我关注的本页底部的自述文件,但是train.py会提示一个持续错误。

当我键入python train.py并插入两个字母的国家/地区代码进行训练时,我仍然收到错误消息:

Processing: ./br/input/lbr.brazil.exp0.box
Executing: /home/sedento/copiaDeUsrBin -l eng ./br/input/lbr.brazil.exp0.tif lbr.brazil.exp0 nobatch box.train.stderr
sh: 1: /home/sedento/copiaDeUsrBin: Permission denied

train.py 请求访问Tesseract bin,我相信它在我的bin文件夹中(几个月后不确定)。所以我复制了一个名为copiaDeUsrBin的bin并在其中使用。错误仍然存​​在,我在copiaDeUsrBin内的所有链接上都使用了。我失去了能力,错误仍然存​​在。chmod -R 777chmod 777sudo

下面的“额外信息”中还有其他错误,我相信它们可能是由这个引起的。有谁知道如何解决权限错误?

谢谢

额外信息:

目前,当我输入时sudo,它会提示

sudo: /etc/sudoers is world writable
sudo: no valid sudoers sources found, quitting
sudo: unable to initialize policy plugin

但我仍然可以使用ls不同于此处的命令。

完整的train.py执行结果如下:

Two-Letter Country Code to Train: br
Processing: ./br/input/lbr.brazil.exp0.box
Executing: /home/sedento/copiaDeUsrBin -l eng ./br/input/lbr.brazil.exp0.tif lbr.brazil.exp0 nobatch box.train.stderr
sh: 1: /home/sedento/copiaDeUsrBin: Permission denied
mv: cannot stat './lbr.brazil.exp0.tr': No such file or directory
mv: cannot stat './lbr.brazil.exp0.txt': No such file or directory
Extracting unicharset from box file ./br/input/lbr.brazil.exp0.box
Other case A of a is not in unicharset
Other case B of b is not in unicharset
Other case C of c is not in unicharset
Other case D of d is not in unicharset
Other case E of e is not in unicharset
Other case F of f is not in unicharset
Other case G of g is not in unicharset
Other case H of h is not in unicharset
Other case I of i is not in unicharset
Other case J of j is not in unicharset
Other case K of k is not in unicharset
Other case L of l is not in unicharset
Other case M of m is not in unicharset
Other case N of n is not in unicharset
Other case O of o is not in unicharset
Other case P of p is not in unicharset
Other case Q of q is not in unicharset
Other case R of r is not in unicharset
Other case S of s is not in unicharset
Other case T of t is not in unicharset
Other case U of u is not in unicharset
Other case V of v is not in unicharset
Other case W of w is not in unicharset
Other case X of x is not in unicharset
Other case Y of y is not in unicharset
Other case Z of z is not in unicharset
Wrote unicharset file unicharset
Executing: /home/sedento/tesseract-ocr/training/mftraining -F ./tmp/font_properties -U unicharset -O ./tmp/lbr.unicharset ./tmp/*.tr
Warning: No shape table file present: shapetable
Reading ./tmp/*.tr ...

Error: Unable to open ./tmp/*.tr!
"Fatal error encountered!" == NULL:Error:Assert failed:in file globaloc.cpp, line 75
Segmentation fault (core dumped)
mv: cannot stat './tmp/lbr.unicharset': No such file or directory
cp: cannot stat './br/input/unicharambigs': No such file or directory
Reading ./tmp/*.tr ...

Error: Unable to open ./tmp/*.tr!
"Fatal error encountered!" == NULL:Error:Assert failed:in file globaloc.cpp, line 75
Segmentation fault (core dumped)
mv: cannot stat './shapetable': No such file or directory
mv: cannot stat './pffmtable': No such file or directory
mv: cannot stat './inttemp': No such file or directory
mv: cannot stat './normproto': No such file or directory
Combining tessdata files
Error: traineddata file must contain at least (a unicharset fileand inttemp) OR an lstm file.
Error combining tessdata files into lbr.traineddata
Version string:4.00.00alpha
23:version:size=12, offset=192
mv: cannot stat './lbr.unicharset': No such file or directory
mv: cannot stat './lbr.shapetable': No such file or directory
mv: cannot stat './lbr.pffmtable': No such file or directory
mv: cannot stat './lbr.inttemp': No such file or directory
mv: cannot stat './lbr.normproto': No such file or directory
mv: cannot stat './lbr.unicharambigs': No such file or directory

我已经安装了 Opencv、Leptonica 和 Tesseract(OpenALPR 的依赖项),但我不明白如何将它们全部集成。Git 的 OpenALPR 编译说明有过时或损坏的链接,所以正如我所说,我正在关注本页底部的自述文件,以及每个依赖项(Tesseract、Leptonica 和 OpenCV)的详细教程。

(附加信息第 2 部分) - 代码 train.py:

#!/usr/bin/python

import os
import glob
import sys

TESSERACT_DIR='/home/sedento/tesseract-ocr'

os.environ["TESSDATA_PREFIX"] = TESSERACT_DIR
#os.system("export TESSDATA_PREFIX=" + TESSERACT_DIR)

TESSERACT_BIN='/usr/bin'
TESSERACT_TRAINDIR= TESSERACT_DIR + '/training'

country = raw_input("Two-Letter Country Code to Train: ").lower()

LANGUAGE_NAME='l' + country

box_files = glob.glob('./' + country + '/input/*.box')

if not box_files:
    print "Cannot find input files"
    sys.exit(1)

os.system("rm ./tmp/*")

font_properties_file = open('./tmp/font_properties','w')

for box_file in box_files:
    print "Processing: " + box_file

    file_without_dir = os.path.split(box_file)[1]
    file_without_ext = os.path.splitext(file_without_dir)[0]
    input_dir = os.path.dirname(box_file)

    tif_file = input_dir + '/' + file_without_ext + ".tif"

    train_cmd = "%s -l eng %s %s nobatch box.train.stderr" % (TESSERACT_BIN, tif_file, file_without_ext)

    print "Executing: " + train_cmd 
    os.system(train_cmd)
    os.system("mv ./" + file_without_ext + ".tr ./tmp/" + file_without_ext + ".tr")
    os.system("mv ./" + file_without_ext + ".txt ./tmp/" + file_without_ext + ".txt")
    font_name=file_without_dir.split('.')[1]
    font_properties_file.write(font_name + ' 0 0 1 0 0\n')

font_properties_file.close()
os.system(TESSERACT_TRAINDIR + "/unicharset_extractor ./" + country + "/input/*.box")
#os.system('mv ./unicharset ./" + country + "/input/" + LANGUAGE_NAME + ".unicharset')
# Shape clustering should currently only be used for the "indic" languages
#train_cmd = TESSERACT_TRAINDIR + '/shapeclustering -F ./' + country + '/input/font_properties -U unicharset ./' + country + '/input/*.tr'
#print "Executing: " + train_cmd
#os.system(train_cmd)

train_cmd = TESSERACT_TRAINDIR + '/mftraining -F ./tmp/font_properties -U unicharset -O ./tmp/' + LANGUAGE_NAME + '.unicharset ./tmp/*.tr'
print "Executing: " + train_cmd
os.system(train_cmd)
os.system("rm ./unicharset")
os.system("mv ./tmp/" + LANGUAGE_NAME + ".unicharset ./")
os.system("cp ./" + country + "/input/unicharambigs ./" + LANGUAGE_NAME + ".unicharambigs")

os.system(TESSERACT_TRAINDIR + '/cntraining ./tmp/*.tr')
#os.system("mv ./unicharset ./" + LANGUAGE_NAME + ".unicharset")
os.system("mv ./shapetable ./" + LANGUAGE_NAME + ".shapetable")
#os.system("rm ./shapetable")
os.system("mv ./pffmtable ./" + LANGUAGE_NAME + ".pffmtable")
os.system("mv ./inttemp ./" + LANGUAGE_NAME + ".inttemp")
os.system("mv ./normproto ./" + LANGUAGE_NAME + ".normproto")

os.system(TESSERACT_TRAINDIR + '/combine_tessdata ' + LANGUAGE_NAME + '.')
# If a config file is in the country's directory, use that.
config_file = os.path.join('./', country, country + '.config')
if os.path.isfile(config_file):
    print "Applying config file: " + config_file
    trainedata_file = LANGUAGE_NAME + '.traineddata'
    os.system(TESSERACT_TRAINDIR + '/combine_tessdata -o ' + trainedata_file + ' ' + config_file )

os.system("mv ./" + LANGUAGE_NAME + ".unicharset ./tmp/")
os.system("mv ./" + LANGUAGE_NAME + ".shapetable ./tmp/")
os.system("mv ./" + LANGUAGE_NAME + ".pffmtable ./tmp/")
os.system("mv ./" + LANGUAGE_NAME + ".inttemp ./tmp/")
os.system("mv ./" + LANGUAGE_NAME + ".normproto ./tmp/")
os.system("mv ./" + LANGUAGE_NAME + ".unicharambigs ./tmp/")
4

0 回答 0