-
-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
35 additions
and
0 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
blockchain_integration/pi_network/dapi/ai/ml/tensorflow/model.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#ifndef MODEL_H | ||
#define MODEL_H | ||
|
||
#include <string> | ||
#include <vector> | ||
#include <tensorflow/cc/ops/standard_ops.h> | ||
#include <tensorflow/cc/saved_model/loader.h> | ||
#include <tensorflow/cc/saved_model/tag_constants.h> | ||
|
||
class Model { | ||
public: | ||
Model(const std::string& model_path); | ||
~Model(); | ||
|
||
// Load the model from a file | ||
void load(); | ||
|
||
// Run the model on input data | ||
std::vector<float> run(const std::vector<float>& input); | ||
|
||
// Get the model's input shape | ||
std::vector<int> get_input_shape() const; | ||
|
||
// Get the model's output shape | ||
std::vector<int> get_output_shape() const; | ||
|
||
private: | ||
std::string model_path_; | ||
tensorflow::Session* session_; | ||
tensorflow::GraphDef graph_def_; | ||
std::vector<tensorflow::Tensor> inputs_; | ||
std::vector<tensorflow::Tensor> outputs_; | ||
}; | ||
|
||
#endif // MODEL_H |