From f02d106e370c13cfb0b3ceb69ad722b97167c16f Mon Sep 17 00:00:00 2001 From: Jonghyun Park Date: Mon, 5 Mar 2018 09:39:37 +0900 Subject: [PATCH] Introduce TensorFlow model encode/decode This commit introduces TensorFlow model encode/decode script based on protoc command. Signed-off-by: Jonghyun Park --- tools/graphdef/README.md | 11 +++++++++++ tools/graphdef/decode.sh | 8 ++++++++ tools/graphdef/encode.sh | 8 ++++++++ 3 files changed, 27 insertions(+) create mode 100644 tools/graphdef/README.md create mode 100755 tools/graphdef/decode.sh create mode 100755 tools/graphdef/encode.sh diff --git a/tools/graphdef/README.md b/tools/graphdef/README.md new file mode 100644 index 0000000..6b11211 --- /dev/null +++ b/tools/graphdef/README.md @@ -0,0 +1,11 @@ +### Prerequisites + - protoc that supports Protocol Buffers language version 3 (a.k.a proto3) + +### How to use +Let's assume that one has *model.txt* and wants to create *model.pb* that corresponds to this *model.txt*. + +Then, one may create *model.pb* using ``encode.sh``: +> cat *model.txt* | ./encode.sh > *model.pb* + +Similarly, one may create *model.txt* from *model.pb* using ``decode.sh``: +> cat *model.pb* | ./decode.sh > *model.txt* diff --git a/tools/graphdef/decode.sh b/tools/graphdef/decode.sh new file mode 100755 index 0000000..58837bd --- /dev/null +++ b/tools/graphdef/decode.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +TOOLCHAIN_BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TENSORFLOW_BASE="${TOOLCHAIN_BASE}/../../externals/tensorflow" + +PROTOC="protoc" + +"${PROTOC}" --proto_path="${TENSORFLOW_BASE}" --decode=tensorflow.GraphDef tensorflow/core/framework/graph.proto diff --git a/tools/graphdef/encode.sh b/tools/graphdef/encode.sh new file mode 100755 index 0000000..ea9a945 --- /dev/null +++ b/tools/graphdef/encode.sh @@ -0,0 +1,8 @@ +#!/bin/sh + +TOOLCHAIN_BASE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +TENSORFLOW_BASE="${TOOLCHAIN_BASE}/../../externals/tensorflow" + +PROTOC="protoc" + +"${PROTOC}" --proto_path="${TENSORFLOW_BASE}" --encode=tensorflow.GraphDef tensorflow/core/framework/graph.proto -- 2.7.4