Register
Login
Resources
Docs Blog Datasets Glossary Case Studies Tutorials & Webinars
Product
Data Engine LLMs Platform Enterprise
Pricing Explore
Connect to our Discord channel

inference.hpp 1.8 KB

You have to be logged in to leave a comment. Sign In
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
  1. // Ultralytics 🚀 AGPL-3.0 License - https://ultralytics.com/license
  2. #pragma once
  3. #include <opencv2/opencv.hpp>
  4. #include "grpc_client.h"
  5. class Image
  6. {
  7. public:
  8. Image() = default;
  9. static void preprocess(cv::Mat* image, std::vector<uint16_t>& triton_data, int input_w, int input_h);
  10. };
  11. struct struct_yolo_output
  12. {
  13. std::vector<int> num_dets, det_classes;
  14. std::vector<float> det_boxes, det_scores;
  15. };
  16. struct BoundingBox {
  17. float x, y, w, h;
  18. float score;
  19. int class_id;
  20. };
  21. struct detection_struct
  22. {
  23. cv::Rect bbox;
  24. int class_id;
  25. std::string name;
  26. double confidence_score;
  27. };
  28. // C-compatible declarations
  29. #ifdef __cplusplus
  30. extern "C" {
  31. #endif
  32. int getDetectionsFromTritonRawData(
  33. std::vector<float>& detection_results,
  34. std::vector<struct detection_struct>& tespitler,
  35. std::vector<std::string>& object_class_list,
  36. float confidence_threshold,
  37. int image_width,
  38. int image_height
  39. );
  40. std::vector<BoundingBox> NMS(const std::vector<BoundingBox>& boxes, float iou_threshold);
  41. float IoU(const BoundingBox& box1, const BoundingBox& box2);
  42. #ifdef __cplusplus
  43. }
  44. #endif
  45. namespace tc = triton::client;
  46. class TritonCommunication
  47. {
  48. private:
  49. std::unique_ptr<tc::InferenceServerGrpcClient> client;
  50. std::string triton_url;
  51. std::vector<int64_t> shape;
  52. tc::InferOptions options;
  53. size_t input_byte_size;
  54. size_t output_byte_size;
  55. std::shared_ptr<tc::InferResult> results_ptr;
  56. public:
  57. std::vector<float> output_raw_data;
  58. TritonCommunication(std::string triton_address,
  59. std::string model_name,
  60. std::string model_version,
  61. int image_channel,
  62. int image_width,
  63. int image_height,
  64. int class_count);
  65. void infer(uint16_t* triton_data);
  66. };
Tip!

Press p or to see the previous file or, n or to see the next file

Comments

Loading...