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

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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. static int test_priorbox_caffe()
  16. {
  17. ncnn::Mat min_sizes(1);
  18. min_sizes[0] = 105.f;
  19. ncnn::Mat max_sizes(1);
  20. max_sizes[0] = 150.f;
  21. ncnn::Mat aspect_ratios(2);
  22. aspect_ratios[0] = 2.f;
  23. aspect_ratios[1] = 3.f;
  24. ncnn::ParamDict pd;
  25. pd.set(0, min_sizes);
  26. pd.set(1, max_sizes);
  27. pd.set(2, aspect_ratios);
  28. pd.set(3, 0.1f); // variances[0]
  29. pd.set(4, 0.1f); // variances[1]
  30. pd.set(5, 0.2f); // variances[2]
  31. pd.set(6, 0.2f); // variances[3]
  32. pd.set(7, 1); // flip
  33. pd.set(8, 0); // clip
  34. pd.set(9, -233); // image_width
  35. pd.set(10, -233); // image_height
  36. pd.set(11, -233.f); // step_width
  37. pd.set(12, -233.f); // step_height
  38. pd.set(13, 0.f); // offset
  39. pd.set(14, 0.f); // step_mmdetection
  40. pd.set(15, 0.f); // center_mmdetection
  41. std::vector<ncnn::Mat> weights(0);
  42. std::vector<ncnn::Mat> as(2);
  43. as[0] = RandomMat(72, 72, 1);
  44. as[1] = RandomMat(512, 512, 1);
  45. int ret = test_layer("PriorBox", pd, weights, as, 1);
  46. if (ret != 0)
  47. {
  48. fprintf(stderr, "test_priorbox_caffe failed\n");
  49. }
  50. return ret;
  51. }
  52. static int test_priorbox_mxnet()
  53. {
  54. ncnn::Mat min_sizes(2);
  55. min_sizes[0] = 0.15f;
  56. min_sizes[1] = 0.2121f;
  57. ncnn::Mat max_sizes(0);
  58. ncnn::Mat aspect_ratios(5);
  59. aspect_ratios[0] = 1.f;
  60. aspect_ratios[1] = 2.f;
  61. aspect_ratios[2] = 0.5f;
  62. aspect_ratios[3] = 3.f;
  63. aspect_ratios[4] = 0.333333;
  64. ncnn::ParamDict pd;
  65. pd.set(0, min_sizes);
  66. pd.set(1, max_sizes);
  67. pd.set(2, aspect_ratios);
  68. pd.set(3, 0.1f); // variances[0]
  69. pd.set(4, 0.1f); // variances[1]
  70. pd.set(5, 0.2f); // variances[2]
  71. pd.set(6, 0.2f); // variances[3]
  72. pd.set(7, 0); // flip
  73. pd.set(8, 0); // clip
  74. pd.set(9, -233); // image_width
  75. pd.set(10, -233); // image_height
  76. pd.set(11, -233.f); // step_width
  77. pd.set(12, -233.f); // step_height
  78. pd.set(13, 0.5f); // offset
  79. pd.set(14, 0.f); // step_mmdetection
  80. pd.set(15, 0.f); // center_mmdetection
  81. std::vector<ncnn::Mat> weights(0);
  82. std::vector<ncnn::Mat> as(1);
  83. as[0] = RandomMat(72, 72, 1);
  84. int ret = test_layer("PriorBox", pd, weights, as, 1);
  85. if (ret != 0)
  86. {
  87. fprintf(stderr, "test_priorbox_mxnet failed\n");
  88. }
  89. return ret;
  90. }
  91. int main()
  92. {
  93. SRAND(7767517);
  94. return 0
  95. || test_priorbox_caffe()
  96. || test_priorbox_mxnet();
  97. }