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
3e33820e
Commit
3e33820e
authored
Nov 17, 2017
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #10104 from wzw-intel:fusion_debug
parents
73d4f12c
394101d6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
61 additions
and
1 deletion
+61
-1
ocl4dnn.hpp
modules/dnn/src/ocl4dnn/include/ocl4dnn.hpp
+1
-1
test_darknet_importer.cpp
modules/dnn/test/test_darknet_importer.cpp
+60
-0
No files found.
modules/dnn/src/ocl4dnn/include/ocl4dnn.hpp
View file @
3e33820e
...
...
@@ -302,7 +302,7 @@ class OCL4DNNConvSpatial
std
::
stringstream
options_
;
cv
::
ocl
::
ProgramSource
src_
;
int32_t
prev_kernel_type_
;
bool
negative_slope_
;
float
negative_slope_
;
UMat
negative_slope_umat_
;
ocl4dnnFusedActiv_t
fused_activ_
;
};
...
...
modules/dnn/test/test_darknet_importer.cpp
View file @
3e33820e
...
...
@@ -44,6 +44,8 @@
#include "test_precomp.hpp"
#include <opencv2/dnn/shape_utils.hpp>
#include <algorithm>
#include <opencv2/core/ocl.hpp>
#include <opencv2/ts/ocl_test.hpp>
namespace
cvtest
{
...
...
@@ -69,6 +71,64 @@ TEST(Test_Darknet, read_yolo_voc)
ASSERT_FALSE
(
net
.
empty
());
}
OCL_TEST
(
Reproducibility_TinyYoloVoc
,
Accuracy
)
{
Net
net
;
{
const
string
cfg
=
findDataFile
(
"dnn/tiny-yolo-voc.cfg"
,
false
);
const
string
model
=
findDataFile
(
"dnn/tiny-yolo-voc.weights"
,
false
);
net
=
readNetFromDarknet
(
cfg
,
model
);
ASSERT_FALSE
(
net
.
empty
());
}
net
.
setPreferableBackend
(
DNN_BACKEND_DEFAULT
);
net
.
setPreferableTarget
(
DNN_TARGET_OPENCL
);
// dog416.png is dog.jpg that resized to 416x416 in the lossless PNG format
Mat
sample
=
imread
(
_tf
(
"dog416.png"
));
ASSERT_TRUE
(
!
sample
.
empty
());
Size
inputSize
(
416
,
416
);
if
(
sample
.
size
()
!=
inputSize
)
resize
(
sample
,
sample
,
inputSize
);
net
.
setInput
(
blobFromImage
(
sample
,
1
/
255.
F
),
"data"
);
Mat
out
=
net
.
forward
(
"detection_out"
);
Mat
detection
;
const
float
confidenceThreshold
=
0.24
;
for
(
int
i
=
0
;
i
<
out
.
rows
;
i
++
)
{
const
int
probability_index
=
5
;
const
int
probability_size
=
out
.
cols
-
probability_index
;
float
*
prob_array_ptr
=
&
out
.
at
<
float
>
(
i
,
probability_index
);
size_t
objectClass
=
std
::
max_element
(
prob_array_ptr
,
prob_array_ptr
+
probability_size
)
-
prob_array_ptr
;
float
confidence
=
out
.
at
<
float
>
(
i
,
(
int
)
objectClass
+
probability_index
);
if
(
confidence
>
confidenceThreshold
)
detection
.
push_back
(
out
.
row
(
i
));
}
// obtained by: ./darknet detector test ./cfg/voc.data ./cfg/tiny-yolo-voc.cfg ./tiny-yolo-voc.weights -thresh 0.24 ./dog416.png
// There are 2 objects (6-car, 11-dog) with 25 values for each:
// { relative_center_x, relative_center_y, relative_width, relative_height, unused_t0, probability_for_each_class[20] }
float
ref_array
[]
=
{
0.736762
F
,
0.239551
F
,
0.315440
F
,
0.160779
F
,
0.761977
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.761967
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.287486
F
,
0.653731
F
,
0.315579
F
,
0.534527
F
,
0.782737
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.780595
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
,
0.000000
F
};
const
int
number_of_objects
=
2
;
Mat
ref
(
number_of_objects
,
sizeof
(
ref_array
)
/
(
number_of_objects
*
sizeof
(
float
)),
CV_32FC1
,
&
ref_array
);
normAssert
(
ref
,
detection
);
}
TEST
(
Reproducibility_TinyYoloVoc
,
Accuracy
)
{
Net
net
;
...
...
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