"火车.py:sh:1:permission denied”在极端chmod R 777和丢失sudo命令后

2024-06-07 00:43:37 发布

您现在位置:Python中文网/ 问答频道 /正文

我想训练OpenALPR的神经网络,在成功安装了它的依赖项之后。我现在只需要执行火车.py,根据我正在跟踪的the readme in the bottom of this page,但是火车.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

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

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

谢谢

额外信息:

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

^{pr2}$

但我仍然可以使用ls这样的命令,与here不同。在

执行火车.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's OpenALPR compilation instructions有过时的或断开的链接,所以正如我所说,我正在关注{a1},以及每个依赖项的详细教程(Tesseract、Leptonica和OpenCV)。在

(额外信息第2部分)-代码火车.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/")

Tags: ofnameinisosnotsystemlanguage