Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/dneprdroid/tfsecured

Small library for TensorFlow proto model's (*.pb) encryption/decryption
https://github.com/dneprdroid/tfsecured

aes cpp decryption encryption golang ios machine-learning tensorflow tensorflow-proto-models

Last synced: 6 days ago
JSON representation

Small library for TensorFlow proto model's (*.pb) encryption/decryption

Awesome Lists containing this project

README

        

## TFSecured

Small library for tensorflow proto models (*.pb) encryption/decryption.

## AES

You may use random string with random length like a key, then library calculates sha256 hash of it and uses as internal key with size 256 bits.

## Usage

Copy sources from [TFSecured](/TFSecured) dir into your project.

C++ usage (see [TFPredictor.mm](/iosDemo/TFSecured-iOS/tf/predict/TFPredictor.mm)):

```cpp

#include

........

tensorflow::GraphDef graph;
// Decryption:
const std::string key = "JHEW8F7FE6F8E76W8F687WE6F8W8EF5";
auto status = tfsecured::GraphDefDecryptAES(path, // path to *.pb file (frozen graph)
&graph,
key); // your key
if (!status.ok()) {
std::cout << status.error_message() << std::endl;
return;
}

// Create session :
std::unique_ptr session(NewSession(options));
status = session->Create(graph);

// Run session ....
```

Encrypt model via python script (see [encrypt_model.py](/python/encrypt_model.py)):

```bash
$ python encrypt_model.py \
\
# optional, generated randomly by script

```

## Dependencies

* TensorFlow

* OpenSSL

## iOS Demo (Digit recognizer)

Prepare repository (install Tensorflow via pods)

```bash

$ cd iosDemo
$ pod install

```
And open it in Xcode.