Files
openvino/docs/snippets/protecting_model_guide.cpp
Ilya Lavrenov 5b3b48aa17 samples overview & model protection: docs (#10596)
* Renamed hetero md

* Renamed some guides

* Updated OpenVINO_Runtime_User_Guide.md

* Updated plugin's page

* More updates

* Fixed links

* Updated link names

* Fixed links

* Fixed docs build

* Self-review

* Fixed issues in doc snippets

* Updated Samples_Overview.md

* Updated model protection guide

* Renamed ngraph_function creation samples
2022-02-22 20:11:42 +03:00

33 lines
851 B
C++

#include <fstream>
#include <vector>
#include "openvino/runtime/core.hpp"
void decrypt_file(std::ifstream & stream,
const std::string & pass,
std::vector<uint8_t> & result) {
}
int main() {
//! [part0]
std::vector<uint8_t> model_data, weights_data;
std::string password; // taken from an user
std::ifstream model_file("model.xml"), weights_file("model.bin");
// Read model files and decrypt them into temporary memory block
decrypt_file(model_file, password, model_data);
decrypt_file(weights_file, password, weights_data);
//! [part0]
//! [part1]
ov::Core core;
// Load model from temporary memory block
std::string str_model(model_data.begin(), model_data.end());
auto model = core.read_model(str_model,
ov::Tensor(ov::element::u8, {weights_data.size()}, weights_data.data()));
//! [part1]
return 0;
}