results.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. // Copyright (c) 2020 PaddlePaddle Authors. All Rights Reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #pragma once
  15. #include <iostream>
  16. #include <string>
  17. #include <vector>
  18. namespace PaddleX {
  19. template <class T>
  20. struct Mask {
  21. std::vector<T> data;
  22. std::vector<int> shape;
  23. void clear() {
  24. data.clear();
  25. shape.clear();
  26. }
  27. };
  28. struct Box {
  29. int category_id;
  30. std::string category;
  31. float score;
  32. std::vector<float> coordinate;
  33. Mask<float> mask;
  34. };
  35. class BaseResult {
  36. public:
  37. std::string type = "base";
  38. };
  39. class ClsResult : public BaseResult {
  40. public:
  41. int category_id;
  42. std::string category;
  43. float score;
  44. std::string type = "cls";
  45. };
  46. class DetResult : public BaseResult {
  47. public:
  48. std::vector<Box> boxes;
  49. int mask_resolution;
  50. std::string type = "det";
  51. void clear() { boxes.clear(); }
  52. };
  53. class SegResult : public BaseResult {
  54. public:
  55. Mask<int64_t> label_map;
  56. Mask<float> score_map;
  57. void clear() {
  58. label_map.clear();
  59. score_map.clear();
  60. }
  61. };
  62. } // namespce of PaddleX