Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
a692d87c
Commit
a692d87c
authored
6 years ago
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #12875 from dkurt:dnn_enet_accuracy
parents
9c9fb1c6
e7015f6a
master
4.3.0
4.2.0
4.1.2
4.1.2-openvino
4.1.1
4.1.1-openvino
4.1.0
4.1.0-openvino
4.0.1
4.0.1-openvino
4.0.0
4.0.0-rc
4.0.0-openvino
3.4.10
3.4.9
3.4.8
3.4.7
3.4.6
3.4.5
3.4.4
No related merge requests found
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
44 additions
and
2 deletions
+44
-2
test_torch_importer.cpp
modules/dnn/test/test_torch_importer.cpp
+44
-2
No files found.
modules/dnn/test/test_torch_importer.cpp
View file @
a692d87c
...
...
@@ -287,6 +287,46 @@ TEST_P(Test_Torch_nets, OpenFace_accuracy)
normAssert
(
out
,
outRef
,
""
,
default_l1
,
default_lInf
);
}
static
Mat
getSegmMask
(
const
Mat
&
scores
)
{
const
int
rows
=
scores
.
size
[
2
];
const
int
cols
=
scores
.
size
[
3
];
const
int
numClasses
=
scores
.
size
[
1
];
Mat
maxCl
=
Mat
::
zeros
(
rows
,
cols
,
CV_8UC1
);
Mat
maxVal
(
rows
,
cols
,
CV_32FC1
,
Scalar
(
0
));
for
(
int
ch
=
0
;
ch
<
numClasses
;
ch
++
)
{
for
(
int
row
=
0
;
row
<
rows
;
row
++
)
{
const
float
*
ptrScore
=
scores
.
ptr
<
float
>
(
0
,
ch
,
row
);
uint8_t
*
ptrMaxCl
=
maxCl
.
ptr
<
uint8_t
>
(
row
);
float
*
ptrMaxVal
=
maxVal
.
ptr
<
float
>
(
row
);
for
(
int
col
=
0
;
col
<
cols
;
col
++
)
{
if
(
ptrScore
[
col
]
>
ptrMaxVal
[
col
])
{
ptrMaxVal
[
col
]
=
ptrScore
[
col
];
ptrMaxCl
[
col
]
=
(
uchar
)
ch
;
}
}
}
}
return
maxCl
;
}
// Computer per-class intersection over union metric.
static
void
normAssertSegmentation
(
const
Mat
&
ref
,
const
Mat
&
test
)
{
CV_Assert_N
(
ref
.
dims
==
4
,
test
.
dims
==
4
);
const
int
numClasses
=
ref
.
size
[
1
];
CV_Assert
(
numClasses
==
test
.
size
[
1
]);
Mat
refMask
=
getSegmMask
(
ref
);
Mat
testMask
=
getSegmMask
(
test
);
EXPECT_EQ
(
countNonZero
(
refMask
!=
testMask
),
0
);
}
TEST_P
(
Test_Torch_nets
,
ENet_accuracy
)
{
checkBackend
();
...
...
@@ -313,14 +353,16 @@ TEST_P(Test_Torch_nets, ENet_accuracy)
// Due to numerical instability in Pooling-Unpooling layers (indexes jittering)
// thresholds for ENet must be changed. Accuracy of results was checked on
// Cityscapes dataset and difference in mIOU with Torch is 10E-4%
normAssert
(
ref
,
out
,
""
,
0.00044
,
/*target == DNN_TARGET_CPU ? 0.453 : */
0.5
);
normAssert
(
ref
,
out
,
""
,
0.00044
,
/*target == DNN_TARGET_CPU ? 0.453 : */
0.552
);
normAssertSegmentation
(
ref
,
out
);
const
int
N
=
3
;
for
(
int
i
=
0
;
i
<
N
;
i
++
)
{
net
.
setInput
(
inputBlob
,
""
);
Mat
out
=
net
.
forward
();
normAssert
(
ref
,
out
,
""
,
0.00044
,
/*target == DNN_TARGET_CPU ? 0.453 : */
0.5
);
normAssert
(
ref
,
out
,
""
,
0.00044
,
/*target == DNN_TARGET_CPU ? 0.453 : */
0.552
);
normAssertSegmentation
(
ref
,
out
);
}
}
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment