Giter Site home page Giter Site logo

yohaneshalim / tfsecured Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dneprdroid/tfsecured

0.0 1.0 0.0 48.38 MB

Small C++ library for TensorFlow proto model's (*.pb) encryption/decryption (with iOS demo).

License: MIT License

Ruby 0.53% Swift 16.24% C 0.46% Objective-C 6.89% C++ 26.13% Objective-C++ 27.42% Python 22.34%

tfsecured's Introduction

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 dir into your project.

C++ usage (see TFPredictor.mm):

    #include <GraphDefDecryptor.hpp>

    ........


    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> session(NewSession(options));
    status = session->Create(graph);
    
    // Run session ....

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

$ python encrypt_model.py <INPUT_PB_MODEL>  \
                          <OUTPUT_PB_MODEL> \  
                          <KEY>                # optional, generated randomly by script 

Dependencies

  • TensorFlow

  • OpenSSL

iOS Demo (Digit recognizer)

Prepare repository (install Tensorflow via pods)

$ cd iosDemo
$ pod install 

And open it in Xcode.

tfsecured's People

Contributors

dneprdroid avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.