DaoAI World C++ SDK
Loading...
Searching...
No Matches
prediction.h
1#pragma once
2#include "common.h"
3
4namespace DaoAI
5{
6 namespace DeepLearning
7 {
8 class PredictionImpl;
9
10 struct Instance
11 {
12 const Box *pred_box;
13 const double *score;
14 const int *pred_class;
15 const std::string* pred_text;
16 const std::string* pred_class_name;
17 const std::vector<Polygon> *pred_mask;
18 const Polygon* pred_flex_box;
19 const std::vector<Point> *pred_keypoints;
20 };
21
22 // Prediction is inference method output. It contains all the useful methods for retrieving results of all tasks but only some are useful depending on the model:
23 // - Object detection: pred_boxes(), scores(), pred_classes(), pred_class_names(), pred_masks() (if model supports instance segmentation), and pred_keypoints() (if model supports keypoint prediction)
24 // - Anomaly detection: scores(), pred_classes() (0: Normal, 1: Anomalous), pred_class_names() ("Normal" or "Anomalous"), and pred_masks().
25 // - Classification: flags().
27 {
28 public:
29
33 DAOAI_API Prediction();
34
38 DAOAI_API ~Prediction();
39
43 DAOAI_API Prediction(const Prediction& prediction);
44
48 Prediction(const PredictionImpl& prediction_impl);
49
54 DAOAI_API std::string toJSONString();
55
59 DAOAI_API Prediction& operator=(const Prediction& prediction);
60
65 DAOAI_API Instance operator[](size_t index) const;
66
71 DAOAI_API int size() const;
72
76 DAOAI_API void push_back(const Instance& instance);
77
82 DAOAI_API const std::vector<Box>& pred_boxes() const;
83
88 DAOAI_API const std::vector<double>& scores() const;
89
94 DAOAI_API const std::vector<int>& pred_classes() const;
95
100 DAOAI_API const std::vector<std::vector<Polygon>>& pred_masks() const;
101
106 DAOAI_API const std::vector<std::string>& pred_class_names() const;
107
112 DAOAI_API const std::vector<std::vector<Point>>& pred_keypoints() const;
113
118 DAOAI_API const std::vector<std::pair<std::string, double>>& flags() const;
119
124 DAOAI_API const bool& is_multilabel() const;
125
130 DAOAI_API const std::vector<std::string>& pred_texts() const;
131
136 DAOAI_API const std::vector<Polygon>& pred_flex_boxes() const;
137
142 DAOAI_API const int& image_width() const;
143
148 DAOAI_API const int& image_height() const;
149
150 private:
151 std::unique_ptr<PredictionImpl> prediction_impl_;
152 };
153
154 }
155}
Definition common.h:48
Definition common.h:32
Definition prediction.h:27
Prediction(const PredictionImpl &prediction_impl)
DAOAI_API const std::vector< std::string > & pred_class_names() const
Get the names of the predicted classes. This is used in object detection and anomaly detection,...
DAOAI_API const std::vector< Polygon > & pred_flex_boxes() const
Get the predicted text bounding box. This is used in OCR, it will be an empty vector for anomaly dete...
DAOAI_API void push_back(const Instance &instance)
DAOAI_API Prediction(const Prediction &prediction)
DAOAI_API const std::vector< double > & scores() const
Get the confidence scores for each predicted bounding box. This is used in object detection and anoma...
DAOAI_API Prediction & operator=(const Prediction &prediction)
DAOAI_API int size() const
DAOAI_API const std::vector< std::vector< Polygon > > & pred_masks() const
Get the predicted masks for each bounding box. This is used in object detection and anomaly detection...
DAOAI_API const std::vector< int > & pred_classes() const
Get the predicted classes for each bounding box. This is used in object detection and anomaly detecti...
DAOAI_API const bool & is_multilabel() const
Check if the classification prediction is multilabel. This is used in classification,...
DAOAI_API std::string toJSONString()
DAOAI_API Instance operator[](size_t index) const
DAOAI_API const int & image_height() const
Get the height of the image associated with the prediction.
DAOAI_API const std::vector< std::string > & pred_texts() const
Get the predicted texts for each bounding box. This is used in OCR, it will be an empty vector for ot...
DAOAI_API const std::vector< Box > & pred_boxes() const
Get the predicted bounding boxes. This is for object detection, will be an empty vector for classific...
DAOAI_API const int & image_width() const
Get the width of the image associated with the prediction.
DAOAI_API const std::vector< std::vector< Point > > & pred_keypoints() const
Get the predicted keypoints for each bounding box. This is used in object detection,...
DAOAI_API const std::vector< std::pair< std::string, double > > & flags() const
Get the label-score pairs associated with the classification prediction. This is used in classificati...
Definition prediction.h:11