Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
a7660331a
tesseract
提交
77c44cde
T
tesseract
项目概览
a7660331a
/
tesseract
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
T
tesseract
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
77c44cde
编写于
8月 02, 2017
作者:
R
Ray Smith
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added convert to int and directory listing to combine_tessdata
上级
2ef1aeae
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
42 addition
and
8 deletion
+42
-8
lstm/lstmrecognizer.h
lstm/lstmrecognizer.h
+8
-0
lstm/lstmtrainer.h
lstm/lstmtrainer.h
+0
-8
training/combine_tessdata.cpp
training/combine_tessdata.cpp
+34
-0
未找到文件。
lstm/lstmrecognizer.h
浏览文件 @
77c44cde
...
...
@@ -127,6 +127,14 @@ class LSTMRecognizer {
series
->
ScaleLayerLearningRate
(
&
id
[
1
],
factor
);
}
// Converts the network to int if not already.
void
ConvertToInt
()
{
if
((
training_flags_
&
TF_INT_MODE
)
==
0
)
{
network_
->
ConvertToInt
();
training_flags_
|=
TF_INT_MODE
;
}
}
// Provides access to the UNICHARSET that this classifier works with.
const
UNICHARSET
&
GetUnicharset
()
const
{
return
ccutil_
.
unicharset
;
}
// Provides access to the UnicharCompress that this classifier works with.
...
...
lstm/lstmtrainer.h
浏览文件 @
77c44cde
...
...
@@ -251,14 +251,6 @@ class LSTMTrainer : public LSTMRecognizer {
const
UnicharCompress
*
recoder
,
bool
simple_text
,
int
null_char
,
GenericVector
<
int
>*
labels
);
// Converts the network to int if not already.
void
ConvertToInt
()
{
if
((
training_flags_
&
TF_INT_MODE
)
==
0
)
{
network_
->
ConvertToInt
();
training_flags_
|=
TF_INT_MODE
;
}
}
// Performs forward-backward on the given trainingdata.
// Returns the sample that was used or NULL if the next sample was deemed
// unusable. samples_trainer could be this or an alternative trainer that
...
...
training/combine_tessdata.cpp
浏览文件 @
77c44cde
...
...
@@ -18,6 +18,7 @@
//
///////////////////////////////////////////////////////////////////////
#include "lstmrecognizer.h"
#include "tessdatamanager.h"
// Main program to combine/extract/overwrite tessdata components
...
...
@@ -122,6 +123,31 @@ int main(int argc, char **argv) {
// Write the updated traineddata file.
tm
.
OverwriteComponents
(
new_traineddata_filename
,
argv
+
3
,
argc
-
3
);
}
else
if
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"-c"
)
==
0
)
{
tm
.
Init
(
argv
[
2
]);
tesseract
::
TFile
fp
;
if
(
!
tm
.
GetComponent
(
tesseract
::
TESSDATA_LSTM
,
&
fp
))
{
tprintf
(
"No LSTM Component found in %s!
\n
"
,
argv
[
2
]);
exit
(
1
);
}
tesseract
::
LSTMRecognizer
recognizer
;
if
(
!
recognizer
.
DeSerialize
(
&
tm
,
&
fp
))
{
tprintf
(
"Failed to deserialize LSTM in %s!
\n
"
,
argv
[
2
]);
exit
(
1
);
}
recognizer
.
ConvertToInt
();
GenericVector
<
char
>
lstm_data
;
fp
.
OpenWrite
(
&
lstm_data
);
ASSERT_HOST
(
recognizer
.
Serialize
(
&
tm
,
&
fp
));
tm
.
OverwriteEntry
(
tesseract
::
TESSDATA_LSTM
,
&
lstm_data
[
0
],
lstm_data
.
size
());
if
(
!
tm
.
SaveFile
(
argv
[
2
],
nullptr
))
{
tprintf
(
"Failed to write modified traineddata:%s!
\n
"
,
argv
[
2
]);
exit
(
1
);
}
}
else
if
(
argc
==
3
&&
strcmp
(
argv
[
1
],
"-d"
)
==
0
)
{
// Initialize TessdataManager with the data in the given traineddata file.
tm
.
Init
(
argv
[
2
]);
}
else
{
printf
(
"Usage for combining tessdata components:
\n
"
" %s language_data_path_prefix
\n
"
...
...
@@ -137,6 +163,14 @@ int main(int argc, char **argv) {
printf
(
"Usage for unpacking all tessdata components:
\n
"
" %s -u traineddata_file output_path_prefix
\n
"
" (e.g. %s -u eng.traineddata tmp/eng.)
\n
"
,
argv
[
0
],
argv
[
0
]);
printf
(
"Usage for listing directory of components:
\n
"
" %s -d traineddata_file
\n
"
,
argv
[
0
]);
printf
(
"Usage for compacting LSTM component to int:
\n
"
" %s -c traineddata_file
\n
"
,
argv
[
0
]);
return
1
;
}
tm
.
Directory
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录