17
static int test_yolov3detectionoutput(const std::vector<ncnn::Mat>& a, int num_class,
18
int num_box, float confidence_threshold, float nms_threshold,
19
ncnn::Mat& biases, ncnn::Mat& mask, ncnn::Mat& anchors_scale)
24
pd.set(2, confidence_threshold);
25
pd.set(3, nms_threshold);
28
pd.set(6, anchors_scale);
30
std::vector<ncnn::Mat> weights(0);
32
int ret = test_layer("Yolov3DetectionOutput", pd, weights, a);
35
fprintf(stderr, "test_yolov3detectionoutput failed a.dims=%d a=(%d %d %d) ", a[0].dims, a[0].w, a[0].h, a[0].c);
36
fprintf(stderr, " num_class=%d num_box=%d", num_class, num_box);
37
fprintf(stderr, " confidence_threshold=%f nms_threshold=%f\n", confidence_threshold, nms_threshold);
43
static ncnn::Mat create_mat_from(const float* src, int length)
45
ncnn::Mat ret(length);
46
memcpy(ret.data, src, length * sizeof(float));
50
static ncnn::Mat MyRandomMat(int w, int h, int c)
53
Randomize(m, -15.f, 1.5f);
57
static int test_yolov3detectionoutput_v4()
59
const float b[] = {12, 16, 19, 36, 40, 28, 36, 75, 76, 55, 72, 146, 142, 110, 192, 243, 459, 401};
60
const float m[] = {0, 1, 2, 3, 4, 5, 6, 7, 8};
61
const float s[] = {9.6, 17.6, 33.6};
63
ncnn::Mat biases = create_mat_from(b, sizeof(b) / sizeof(b[0]));
64
ncnn::Mat mask = create_mat_from(m, sizeof(m) / sizeof(m[0]));
65
ncnn::Mat anchors_scale = create_mat_from(s, sizeof(s) / sizeof(s[0]));
67
std::vector<ncnn::Mat> a(3);
68
a[0] = MyRandomMat(76, 76, 255);
69
a[1] = MyRandomMat(38, 38, 255);
70
a[2] = MyRandomMat(19, 19, 255);
73
|| test_yolov3detectionoutput(a, 80, 3, 0.55f, 0.45f, biases, mask, anchors_scale);
76
static int test_yolov3detectionoutput_v4tiny()
78
const float b[] = {10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319};
79
const float m[] = {3, 4, 5, 1, 2, 3};
80
const float s[] = {33.6, 16.8};
82
ncnn::Mat biases = create_mat_from(b, sizeof(b) / sizeof(b[0]));
83
ncnn::Mat mask = create_mat_from(m, sizeof(m) / sizeof(m[0]));
84
ncnn::Mat anchors_scale = create_mat_from(s, sizeof(s) / sizeof(s[0]));
86
std::vector<ncnn::Mat> a(2);
87
a[0] = MyRandomMat(13, 13, 255);
88
a[1] = MyRandomMat(26, 26, 255);
91
|| test_yolov3detectionoutput(a, 80, 3, 0.4f, 0.45f, biases, mask, anchors_scale);
94
static int test_yolov3detectionoutput_v3()
96
const float b[] = {10, 13, 16, 30, 33, 23, 30, 61, 62, 45, 59, 119, 116, 90, 156, 198, 373, 326};
97
const float m[] = {6, 7, 8, 3, 4, 5, 0, 1, 2};
98
const float s[] = {32, 16, 8};
100
ncnn::Mat biases = create_mat_from(b, sizeof(b) / sizeof(b[0]));
101
ncnn::Mat mask = create_mat_from(m, sizeof(m) / sizeof(m[0]));
102
ncnn::Mat anchors_scale = create_mat_from(s, sizeof(s) / sizeof(s[0]));
104
std::vector<ncnn::Mat> a(3);
105
a[0] = MyRandomMat(19, 19, 255);
106
a[1] = MyRandomMat(38, 38, 255);
107
a[2] = MyRandomMat(76, 76, 255);
110
|| test_yolov3detectionoutput(a, 80, 3, 0.6f, 0.45f, biases, mask, anchors_scale);
113
static int test_yolov3detectionoutput_v3tiny()
115
const float b[] = {10, 14, 23, 27, 37, 58, 81, 82, 135, 169, 344, 319};
116
const float m[] = {3, 4, 5, 1, 2, 3};
117
const float s[] = {32, 16};
119
ncnn::Mat biases = create_mat_from(b, sizeof(b) / sizeof(b[0]));
120
ncnn::Mat mask = create_mat_from(m, sizeof(m) / sizeof(m[0]));
121
ncnn::Mat anchors_scale = create_mat_from(s, sizeof(s) / sizeof(s[0]));
123
std::vector<ncnn::Mat> a(2);
124
a[0] = MyRandomMat(13, 13, 255);
125
a[1] = MyRandomMat(26, 26, 255);
128
|| test_yolov3detectionoutput(a, 80, 3, 0.3f, 0.45f, biases, mask, anchors_scale);
136
|| test_yolov3detectionoutput_v3tiny()
137
|| test_yolov3detectionoutput_v3()
138
|| test_yolov3detectionoutput_v4tiny()
139
|| test_yolov3detectionoutput_v4();