Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
FrankJule
License Plate Detect Recognition Via Deep Neural Networks Accuracy Up To 99.9
提交
548fde32
L
License Plate Detect Recognition Via Deep Neural Networks Accuracy Up To 99.9
项目概览
FrankJule
/
License Plate Detect Recognition Via Deep Neural Networks Accuracy Up To 99.9
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
License Plate Detect Recognition Via Deep Neural Networks Accuracy Up To 99.9
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
548fde32
编写于
7月 20, 2018
作者:
朱
朱本福
提交者:
GitHub
7月 20, 2018
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add files via upload
上级
59457fdc
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
203 addition
and
0 deletion
+203
-0
ocr_test/ctcpp_entrypoint.cpp
ocr_test/ctcpp_entrypoint.cpp
+203
-0
未找到文件。
ocr_test/ctcpp_entrypoint.cpp
0 → 100644
浏览文件 @
548fde32
#include <cstddef>
#include <iostream>
#include <algorithm>
#include <ctcpp.h>
#include "detail/cpu_ctc.h"
namespace
CTC
{
int
get_warpctc_version
()
{
return
2
;
}
const
char
*
ctcGetStatusString
(
ctcStatus_t
status
)
{
switch
(
status
)
{
case
CTC_STATUS_SUCCESS
:
return
"no error"
;
case
CTC_STATUS_MEMOPS_FAILED
:
return
"cuda memcpy or memset failed"
;
case
CTC_STATUS_INVALID_VALUE
:
return
"invalid value"
;
case
CTC_STATUS_EXECUTION_FAILED
:
return
"execution failed"
;
case
CTC_STATUS_UNKNOWN_ERROR
:
default:
return
"unknown error"
;
}
}
template
<
typename
Dtype
>
ctcStatus_t
compute_ctc_loss_cpu
(
const
Dtype
*
const
activations
,
Dtype
*
gradients
,
const
int
*
const
flat_labels
,
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
Dtype
*
costs
,
void
*
workspace
,
ctcOptions
options
)
{
if
(
activations
==
nullptr
||
flat_labels
==
nullptr
||
label_lengths
==
nullptr
||
input_lengths
==
nullptr
||
costs
==
nullptr
||
workspace
==
nullptr
||
alphabet_size
<=
0
||
minibatch
<=
0
)
return
CTC_STATUS_INVALID_VALUE
;
if
(
options
.
loc
==
CTC_CPU
)
{
CpuCTC
<
Dtype
>
ctc
(
alphabet_size
,
minibatch
,
workspace
,
options
.
num_threads
,
options
.
blank_label
);
if
(
gradients
!=
NULL
)
return
ctc
.
cost_and_grad
(
activations
,
gradients
,
costs
,
flat_labels
,
label_lengths
,
input_lengths
);
else
return
ctc
.
score_forward
(
activations
,
costs
,
flat_labels
,
label_lengths
,
input_lengths
);
}
else
if
(
options
.
loc
==
CTC_GPU
)
{
}
else
{
return
CTC_STATUS_INVALID_VALUE
;
}
return
CTC_STATUS_SUCCESS
;
}
template
<
typename
Dtype
>
ctcStatus_t
get_workspace_size
(
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
ctcOptions
options
,
size_t
*
size_bytes
)
{
if
(
label_lengths
==
nullptr
||
input_lengths
==
nullptr
||
size_bytes
==
nullptr
||
alphabet_size
<=
0
||
minibatch
<=
0
)
return
CTC_STATUS_INVALID_VALUE
;
// This is the max of all S and T for all examples in the minibatch.
int
maxL
=
*
std
::
max_element
(
label_lengths
,
label_lengths
+
minibatch
);
int
maxT
=
*
std
::
max_element
(
input_lengths
,
input_lengths
+
minibatch
);
const
int
S
=
2
*
maxL
+
1
;
*
size_bytes
=
0
;
if
(
options
.
loc
==
CTC_GPU
)
{
// GPU storage
//nll_forward, nll_backward
*
size_bytes
+=
2
*
sizeof
(
Dtype
)
*
minibatch
;
//repeats
*
size_bytes
+=
sizeof
(
int
)
*
minibatch
;
//label offsets
*
size_bytes
+=
sizeof
(
int
)
*
minibatch
;
//utt_length
*
size_bytes
+=
sizeof
(
int
)
*
minibatch
;
//label lengths
*
size_bytes
+=
sizeof
(
int
)
*
minibatch
;
//labels without blanks - overallocate for now
*
size_bytes
+=
sizeof
(
int
)
*
maxL
*
minibatch
;
//labels with blanks
*
size_bytes
+=
sizeof
(
int
)
*
S
*
minibatch
;
//alphas
*
size_bytes
+=
sizeof
(
Dtype
)
*
S
*
maxT
*
minibatch
;
//denoms
*
size_bytes
+=
sizeof
(
Dtype
)
*
maxT
*
minibatch
;
//probs (since we will pass in activations)
*
size_bytes
+=
sizeof
(
Dtype
)
*
alphabet_size
*
maxT
*
minibatch
;
}
else
{
//cpu can eventually replace all minibatch with
//max number of concurrent threads if memory is
//really tight
//per minibatch memory
size_t
per_minibatch_bytes
=
0
;
//output
per_minibatch_bytes
+=
sizeof
(
Dtype
)
*
alphabet_size
;
//alphas
per_minibatch_bytes
+=
sizeof
(
Dtype
)
*
S
*
maxT
;
//betas
per_minibatch_bytes
+=
sizeof
(
Dtype
)
*
S
;
//labels w/blanks, e_inc, s_inc
per_minibatch_bytes
+=
3
*
sizeof
(
int
)
*
S
;
*
size_bytes
=
per_minibatch_bytes
*
minibatch
;
//probs
*
size_bytes
+=
sizeof
(
Dtype
)
*
alphabet_size
*
maxT
*
minibatch
;
}
return
CTC_STATUS_SUCCESS
;
}
template
ctcStatus_t
compute_ctc_loss_cpu
<
float
>(
const
float
*
const
activations
,
float
*
gradients
,
const
int
*
const
flat_labels
,
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
float
*
costs
,
void
*
workspace
,
ctcOptions
options
);
template
ctcStatus_t
compute_ctc_loss_cpu
<
double
>(
const
double
*
const
activations
,
double
*
gradients
,
const
int
*
const
flat_labels
,
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
double
*
costs
,
void
*
workspace
,
ctcOptions
);
template
ctcStatus_t
get_workspace_size
<
float
>(
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
ctcOptions
,
size_t
*
size_bytes
);
template
ctcStatus_t
get_workspace_size
<
double
>(
const
int
*
const
label_lengths
,
const
int
*
const
input_lengths
,
int
alphabet_size
,
int
minibatch
,
ctcOptions
,
size_t
*
size_bytes
);
}
// namespace ctc
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录