Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Pinoxchio
apollo
提交
8ce0d74e
A
apollo
项目概览
Pinoxchio
/
apollo
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
A
apollo
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
8ce0d74e
编写于
9月 24, 2020
作者:
D
Dontmovedad
提交者:
Qi Luo
9月 28, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Obstacel Detector: Fix inference input dimension
上级
d8926d46
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
12 deletion
+17
-12
modules/perception/inference/onnx/libtorch_obstacle_detector.cc
...s/perception/inference/onnx/libtorch_obstacle_detector.cc
+11
-9
modules/perception/inference/onnx/libtorch_obstacle_detector.h
...es/perception/inference/onnx/libtorch_obstacle_detector.h
+5
-1
modules/perception/inference/onnx/libtorch_obstacle_detector_test.cc
...ception/inference/onnx/libtorch_obstacle_detector_test.cc
+1
-2
未找到文件。
modules/perception/inference/onnx/libtorch_obstacle_detector.cc
浏览文件 @
8ce0d74e
...
...
@@ -32,33 +32,35 @@ LibtorchObstacleDetection::LibtorchObstacleDetection() : device_(torch::kCPU) {
}
bool
LibtorchObstacleDetection
::
Evaluate
(
const
std
::
vector
<
std
::
vector
<
double
>>&
imageFrame
)
{
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>>&
imageFrame
)
{
// Sanity checks.
omp_set_num_threads
(
1
);
if
(
imageFrame
.
size
()
==
0
)
{
A
INFO
<<
"Got no channel in image frame!"
;
A
ERROR
<<
"Got no channel in image frame!"
;
return
false
;
}
if
(
imageFrame
[
0
].
size
()
==
0
)
{
A
INFO
<<
"Got no image frame in channel 0!"
;
A
ERROR
<<
"Got no image frame in channel 0!"
;
return
false
;
}
if
(
imageFrame
[
0
].
size
()
!=
72000
)
{
A
INFO
<<
"imageFrame[0].size() = "
<<
imageFrame
[
0
].
size
()
<<
", skiping!"
;
if
(
imageFrame
[
0
].
size
()
!=
369664
)
{
A
ERROR
<<
"imageFrame[0].size() = "
<<
imageFrame
[
0
].
size
()
<<
", skiping!"
;
return
false
;
}
// image imput size is
1920 * 1080 = 2073600
torch
::
Tensor
image_tensor
=
torch
::
empty
(
32
*
3
*
3
*
3
);
// image imput size is
608 * 608 = 369664
torch
::
Tensor
image_tensor
=
torch
::
empty
(
1
*
3
*
608
*
608
);
float
*
data
=
image_tensor
.
data_ptr
<
float
>
();
for
(
const
auto
&
channel
:
imageFrame
)
{
for
(
const
auto
&
i
:
channel
)
{
*
data
++
=
static_cast
<
float
>
(
i
)
/
32767.0
;
for
(
const
auto
&
j
:
i
)
{
*
data
++
=
static_cast
<
float
>
(
j
)
/
255.0
;
}
}
}
torch
::
Tensor
torch_input
=
torch
::
from_blob
(
image_tensor
.
data_ptr
<
float
>
(),
{
32
,
3
,
3
,
3
,
3
});
{
1
,
3
,
608
,
608
});
std
::
vector
<
torch
::
jit
::
IValue
>
torch_inputs
;
torch_inputs
.
push_back
(
torch_input
.
to
(
device_
));
...
...
modules/perception/inference/onnx/libtorch_obstacle_detector.h
浏览文件 @
8ce0d74e
...
...
@@ -20,6 +20,10 @@
#include "torch/script.h"
#include "torch/torch.h"
#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
namespace
apollo
{
namespace
perception
{
namespace
inference
{
...
...
@@ -30,7 +34,7 @@ class LibtorchObstacleDetection {
~
LibtorchObstacleDetection
()
=
default
;
bool
Evaluate
(
const
std
::
vector
<
std
::
vector
<
double
>>&
imageFrame
);
bool
Evaluate
(
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>
>>&
imageFrame
);
private:
void
LoadModel
();
...
...
modules/perception/inference/onnx/libtorch_obstacle_detector_test.cc
浏览文件 @
8ce0d74e
...
...
@@ -32,8 +32,7 @@ class LibtorchObstacleDetectionTest : public ::testing::Test {
};
TEST_F
(
LibtorchObstacleDetectionTest
,
is_
)
{
std
::
vector
<
std
::
vector
<
double
>>
imageFrame
(
4
,
(
std
::
vector
<
double
>
(
2073600
,
0.01
)));
std
::
vector
<
std
::
vector
<
std
::
vector
<
double
>>>
imageFrame
(
3
,
std
::
vector
<
std
::
vector
<
double
>>
(
608
,
std
::
vector
<
double
>
(
608
,
0.01
)));
bool
result
=
obstacle_detection_
.
Evaluate
(
imageFrame
);
EXPECT_EQ
(
result
,
false
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录