You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_priorbox.cpp 3.4 kB

6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. // Tencent is pleased to support the open source community by making ncnn available.
  2. //
  3. // Copyright (C) 2020 THL A29 Limited, a Tencent company. All rights reserved.
  4. //
  5. // Licensed under the BSD 3-Clause License (the "License"); you may not use this file except
  6. // in compliance with the License. You may obtain a copy of the License at
  7. //
  8. // https://opensource.org/licenses/BSD-3-Clause
  9. //
  10. // Unless required by applicable law or agreed to in writing, software distributed
  11. // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
  12. // CONDITIONS OF ANY KIND, either express or implied. See the License for the
  13. // specific language governing permissions and limitations under the License.
  14. #include "testutil.h"
  15. #include "layer/priorbox.h"
  16. static int test_priorbox_caffe()
  17. {
  18. ncnn::Mat min_sizes(1);
  19. min_sizes[0] = 105.f;
  20. ncnn::Mat max_sizes(1);
  21. max_sizes[0] = 150.f;
  22. ncnn::Mat aspect_ratios(2);
  23. aspect_ratios[0] = 2.f;
  24. aspect_ratios[1] = 3.f;
  25. ncnn::ParamDict pd;
  26. pd.set(0, min_sizes);
  27. pd.set(1, max_sizes);
  28. pd.set(2, aspect_ratios);
  29. pd.set(3, 0.1f);// variances[0]
  30. pd.set(4, 0.1f);// variances[1]
  31. pd.set(5, 0.2f);// variances[2]
  32. pd.set(6, 0.2f);// variances[3]
  33. pd.set(7, 1);// flip
  34. pd.set(8, 0);// clip
  35. pd.set(9, -233);// image_width
  36. pd.set(10, -233);// image_height
  37. pd.set(11, -233.f);// step_width
  38. pd.set(12, -233.f);// step_height
  39. pd.set(13, 0.f);// offset
  40. pd.set(14, 0.f);// step_mmdetection
  41. pd.set(15, 0.f);// center_mmdetection
  42. std::vector<ncnn::Mat> weights(0);
  43. std::vector<ncnn::Mat> as(2);
  44. as[0] = RandomMat(72, 72, 1);
  45. as[1] = RandomMat(512, 512, 1);
  46. ncnn::Option opt;
  47. opt.num_threads = 1;
  48. opt.use_vulkan_compute = true;
  49. opt.use_int8_inference = false;
  50. int ret = test_layer<ncnn::PriorBox>("PriorBox", pd, weights, opt, as, 1);
  51. if (ret != 0)
  52. {
  53. fprintf(stderr, "test_priorbox_caffe failed\n");
  54. }
  55. return ret;
  56. }
  57. static int test_priorbox_mxnet()
  58. {
  59. ncnn::Mat min_sizes(2);
  60. min_sizes[0] = 0.15f;
  61. min_sizes[1] = 0.2121f;
  62. ncnn::Mat max_sizes(0);
  63. ncnn::Mat aspect_ratios(5);
  64. aspect_ratios[0] = 1.f;
  65. aspect_ratios[1] = 2.f;
  66. aspect_ratios[2] = 0.5f;
  67. aspect_ratios[3] = 3.f;
  68. aspect_ratios[4] = 0.333333;
  69. ncnn::ParamDict pd;
  70. pd.set(0, min_sizes);
  71. pd.set(1, max_sizes);
  72. pd.set(2, aspect_ratios);
  73. pd.set(3, 0.1f);// variances[0]
  74. pd.set(4, 0.1f);// variances[1]
  75. pd.set(5, 0.2f);// variances[2]
  76. pd.set(6, 0.2f);// variances[3]
  77. pd.set(7, 0);// flip
  78. pd.set(8, 0);// clip
  79. pd.set(9, -233);// image_width
  80. pd.set(10, -233);// image_height
  81. pd.set(11, -233.f);// step_width
  82. pd.set(12, -233.f);// step_height
  83. pd.set(13, 0.5f);// offset
  84. pd.set(14, 0.f);// step_mmdetection
  85. pd.set(15, 0.f);// center_mmdetection
  86. std::vector<ncnn::Mat> weights(0);
  87. std::vector<ncnn::Mat> as(1);
  88. as[0] = RandomMat(72, 72, 1);
  89. ncnn::Option opt;
  90. opt.num_threads = 1;
  91. opt.use_vulkan_compute = true;
  92. opt.use_int8_inference = false;
  93. int ret = test_layer<ncnn::PriorBox>("PriorBox", pd, weights, opt, as, 1);
  94. if (ret != 0)
  95. {
  96. fprintf(stderr, "test_priorbox_mxnet failed\n");
  97. }
  98. return ret;
  99. }
  100. int main()
  101. {
  102. SRAND(7767517);
  103. return 0
  104. || test_priorbox_caffe()
  105. || test_priorbox_mxnet()
  106. ;
  107. }