Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Greenplum
Opencv
提交
b122a4b4
O
Opencv
项目概览
Greenplum
/
Opencv
10 个月 前同步成功
通知
7
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
O
Opencv
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
b122a4b4
编写于
5月 22, 2023
作者:
A
Alexander Smorkalov
提交者:
GitHub
5月 22, 2023
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #23646 from dkurt:dnn_ie_region_fix
Fix Region layer with OpenVINO in case of different width/height
上级
99760742
af147805
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
30 addition
and
9 deletion
+30
-9
modules/dnn/src/layers/region_layer.cpp
modules/dnn/src/layers/region_layer.cpp
+3
-3
modules/dnn/test/test_darknet_importer.cpp
modules/dnn/test/test_darknet_importer.cpp
+27
-6
未找到文件。
modules/dnn/src/layers/region_layer.cpp
浏览文件 @
b122a4b4
...
...
@@ -526,14 +526,14 @@ public:
std
::
vector
<
float
>
x_indices
(
w
*
h
*
anchors
);
auto
begin
=
x_indices
.
begin
();
for
(
int
i
=
0
;
i
<
h
;
i
++
)
for
(
int
i
=
0
;
i
<
w
;
i
++
)
{
std
::
fill
(
begin
+
i
*
anchors
,
begin
+
(
i
+
1
)
*
anchors
,
i
);
}
for
(
int
j
=
1
;
j
<
w
;
j
++
)
for
(
int
j
=
1
;
j
<
h
;
j
++
)
{
std
::
copy
(
begin
,
begin
+
h
*
anchors
,
begin
+
j
*
h
*
anchors
);
std
::
copy
(
begin
,
begin
+
w
*
anchors
,
begin
+
j
*
w
*
anchors
);
}
auto
horiz
=
std
::
make_shared
<
ngraph
::
op
::
Constant
>
(
ngraph
::
element
::
f32
,
box_broad_shape
,
x_indices
.
data
());
box_x
=
std
::
make_shared
<
ngraph
::
op
::
v1
::
Add
>
(
box_x
,
horiz
,
ngraph
::
op
::
AutoBroadcastType
::
NUMPY
);
...
...
modules/dnn/test/test_darknet_importer.cpp
浏览文件 @
b122a4b4
...
...
@@ -181,12 +181,21 @@ public:
const
std
::
vector
<
std
::
vector
<
float
>
>&
refConfidences
,
const
std
::
vector
<
std
::
vector
<
Rect2d
>
>&
refBoxes
,
double
scoreDiff
,
double
iouDiff
,
float
confThreshold
=
0.24
,
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
)
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
,
int
zeroPadW
=
0
)
{
checkBackend
();
Mat
img1
=
imread
(
_tf
(
"dog416.png"
));
Mat
img2
=
imread
(
_tf
(
"street.png"
));
cv
::
resize
(
img2
,
img2
,
Size
(
416
,
416
));
// Pad images by black pixel at the right to test not equal width and height sizes
if
(
zeroPadW
)
{
cv
::
copyMakeBorder
(
img1
,
img1
,
0
,
0
,
0
,
zeroPadW
,
BORDER_CONSTANT
);
cv
::
copyMakeBorder
(
img2
,
img2
,
0
,
0
,
0
,
zeroPadW
,
BORDER_CONSTANT
);
}
std
::
vector
<
Mat
>
samples
(
2
);
samples
[
0
]
=
img1
;
samples
[
1
]
=
img2
;
...
...
@@ -195,7 +204,7 @@ public:
CV_Assert
(
batch_size
==
1
||
batch_size
==
2
);
samples
.
resize
(
batch_size
);
Mat
inp
=
blobFromImages
(
samples
,
1.0
/
255
,
Size
(
416
,
416
),
Scalar
(),
true
,
false
);
Mat
inp
=
blobFromImages
(
samples
,
1.0
/
255
,
Size
(),
Scalar
(),
true
,
false
);
Net
net
=
readNet
(
findDataFile
(
"dnn/"
+
cfg
),
findDataFile
(
"dnn/"
+
weights
,
false
));
...
...
@@ -275,6 +284,14 @@ public:
continue
;
}
// Return predictions from padded image to the origin
if
(
zeroPadW
)
{
float
scale
=
static_cast
<
float
>
(
inp
.
size
[
3
])
/
(
inp
.
size
[
3
]
-
zeroPadW
);
for
(
auto
&
box
:
nms_boxes
)
{
box
.
x
*=
scale
;
box
.
width
*=
scale
;
}
}
normAssertDetections
(
refClassIds
[
b
],
refConfidences
[
b
],
refBoxes
[
b
],
nms_classIds
,
nms_confidences
,
nms_boxes
,
format
(
"batch size %d, sample %d
\n
"
,
batch_size
,
b
).
c_str
(),
confThreshold
,
scoreDiff
,
iouDiff
);
}
...
...
@@ -285,18 +302,20 @@ public:
const
std
::
vector
<
float
>&
refConfidences
,
const
std
::
vector
<
Rect2d
>&
refBoxes
,
double
scoreDiff
,
double
iouDiff
,
float
confThreshold
=
0.24
,
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
)
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
,
int
zeroPadW
=
0
)
{
testDarknetModel
(
cfg
,
weights
,
std
::
vector
<
std
::
vector
<
int
>
>
(
1
,
refClassIds
),
std
::
vector
<
std
::
vector
<
float
>
>
(
1
,
refConfidences
),
std
::
vector
<
std
::
vector
<
Rect2d
>
>
(
1
,
refBoxes
),
scoreDiff
,
iouDiff
,
confThreshold
,
nmsThreshold
,
useWinograd
);
scoreDiff
,
iouDiff
,
confThreshold
,
nmsThreshold
,
useWinograd
,
zeroPadW
);
}
void
testDarknetModel
(
const
std
::
string
&
cfg
,
const
std
::
string
&
weights
,
const
cv
::
Mat
&
ref
,
double
scoreDiff
,
double
iouDiff
,
float
confThreshold
=
0.24
,
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
)
float
confThreshold
=
0.24
,
float
nmsThreshold
=
0.4
,
bool
useWinograd
=
true
,
int
zeroPadW
=
0
)
{
CV_Assert
(
ref
.
cols
==
7
);
std
::
vector
<
std
::
vector
<
int
>
>
refClassIds
;
...
...
@@ -323,7 +342,7 @@ public:
refBoxes
[
batchId
].
push_back
(
box
);
}
testDarknetModel
(
cfg
,
weights
,
refClassIds
,
refScores
,
refBoxes
,
scoreDiff
,
iouDiff
,
confThreshold
,
nmsThreshold
,
useWinograd
);
scoreDiff
,
iouDiff
,
confThreshold
,
nmsThreshold
,
useWinograd
,
zeroPadW
);
}
};
...
...
@@ -767,6 +786,8 @@ TEST_P(Test_Darknet_nets, YOLOv4)
{
SCOPED_TRACE
(
"batch size 1"
);
testDarknetModel
(
config_file
,
weights_file
,
ref
.
rowRange
(
0
,
N0
),
scoreDiff
,
iouDiff
,
0.24
,
0.4
,
false
);
// Test not equal width and height applying zero padding
testDarknetModel
(
config_file
,
weights_file
,
ref
.
rowRange
(
0
,
N0
),
0.006
,
0.008
,
0.24
,
0.4
,
false
,
/*zeroPadW*/
32
);
}
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录