Lens AI Profiler Cpp
modelprofile.h
1 
6 #ifndef MODEL_STATS_H
7 #define MODEL_STATS_H
8 
9 #include <string>
10 #include <vector>
11 #include <map>
12 #include "saver.h"
13 #include "generic.h"
14 #include <kll_sketch.hpp>
15 #include <frequent_items_sketch.hpp>
16 
17 // Assuming declarations for Saver, distributionBox, ClassificationResult, and YoloDetection
18 
23 typedef std::vector<std::pair<float, int>> ClassificationResults;
25 
26 class ModelProfile {
27 public:
34  ModelProfile(std::string model_id, std::string conf_path,
35  int save_interval, int top_classes);
36  ~ModelProfile();
37 
44  int log_classification_model_stats(float inference_latency, const ClassificationResults& results);
50  int log_embeddings(const std::vector<float>& embeddings);
57  int log_embeddings(const std::vector<float>& embeddings, int cls);
58 
59  frequent_class_sketch *sketch1;
60  int getNumDistributionBoxes() const;
61  const distributionBox& getDistributionBox(unsigned int index) const;
62  void registerStatistics();
63 #ifndef TEST
64  private:
65 #endif
66 
67  Saver *saver;
68  // Member variables (declarations only, definitions in .cpp file)
69  std::string model_id_;
70  int top_classes_;
71  std::string statSavepath;
72  std::string dataSavepath;
73  std::map<std::string, std::vector<std::string>> modelConfig;
74  std::vector<float> inference_latency_;
75  std::vector<int> no_detections_per_image_;
76  std::vector<double> objectnessbox_;
77  distributionBox *dBox;
78  std::map<int, distributionBox*> model_classes_stat_;
79  distributionBox *model_embeddings;
86  distributionBox* getBox(const int cls);
87  // Map to store KLL sketches based on statistic names
88  std::unordered_map<int, distributionBox*> embeddings_stat_;
89 
90 };
91 
92 #endif // MODEL_STATS_H
Class for computing and managing various model statistics.
Definition: modelprofile.h:26
ModelProfile(std::string model_id, std::string conf_path, int save_interval, int top_classes)
Constructor to initialize ModelProfile object.
Definition: modelprofile.cpp:25
int log_classification_model_stats(float inference_latency, const ClassificationResults &results)
Logs statistics for a classification model.
Definition: modelprofile.cpp:73
int log_embeddings(const std::vector< float > &embeddings)
Logs model embeddings from the model.
Definition: modelprofile.cpp:98
Definition: saver.h:39
Definition: frequent_items_sketch.hpp:55