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.3 kB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  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 "layer/priorbox.h"
  15. #include "testutil.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. int ret = test_layer<ncnn::PriorBox>("PriorBox", pd, weights, as, 1);
  47. if (ret != 0)
  48. {
  49. fprintf(stderr, "test_priorbox_caffe failed\n");
  50. }
  51. return ret;
  52. }
  53. static int test_priorbox_mxnet()
  54. {
  55. ncnn::Mat min_sizes(2);
  56. min_sizes[0] = 0.15f;
  57. min_sizes[1] = 0.2121f;
  58. ncnn::Mat max_sizes(0);
  59. ncnn::Mat aspect_ratios(5);
  60. aspect_ratios[0] = 1.f;
  61. aspect_ratios[1] = 2.f;
  62. aspect_ratios[2] = 0.5f;
  63. aspect_ratios[3] = 3.f;
  64. aspect_ratios[4] = 0.333333;
  65. ncnn::ParamDict pd;
  66. pd.set(0, min_sizes);
  67. pd.set(1, max_sizes);
  68. pd.set(2, aspect_ratios);
  69. pd.set(3, 0.1f); // variances[0]
  70. pd.set(4, 0.1f); // variances[1]
  71. pd.set(5, 0.2f); // variances[2]
  72. pd.set(6, 0.2f); // variances[3]
  73. pd.set(7, 0); // flip
  74. pd.set(8, 0); // clip
  75. pd.set(9, -233); // image_width
  76. pd.set(10, -233); // image_height
  77. pd.set(11, -233.f); // step_width
  78. pd.set(12, -233.f); // step_height
  79. pd.set(13, 0.5f); // offset
  80. pd.set(14, 0.f); // step_mmdetection
  81. pd.set(15, 0.f); // center_mmdetection
  82. std::vector<ncnn::Mat> weights(0);
  83. std::vector<ncnn::Mat> as(1);
  84. as[0] = RandomMat(72, 72, 1);
  85. int ret = test_layer<ncnn::PriorBox>("PriorBox", pd, weights, as, 1);
  86. if (ret != 0)
  87. {
  88. fprintf(stderr, "test_priorbox_mxnet failed\n");
  89. }
  90. return ret;
  91. }
  92. int main()
  93. {
  94. SRAND(7767517);
  95. return 0
  96. || test_priorbox_caffe()
  97. || test_priorbox_mxnet();
  98. }