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

https://github.com/chunyang-wen/prototext-tensorflow

generate pb_text* from proto in tensorflow
https://github.com/chunyang-wen/prototext-tensorflow

protobuf prototext tensorflow

Last synced: about 1 month ago
JSON representation

generate pb_text* from proto in tensorflow

Awesome Lists containing this project

README

          

Tensorflow has a tool called `prototext`.

It is bundled with Tensorflow so tightly. This repo extracts essential code.

### Install google protobuf

You have to install protobuf and then change the locations in CMakeLists.txt

On Mac:

```bash
brew install automake libtool
```

```bash
git clone https://github.com/google/protobuf
# cd to protobuf directory
mkdir output
./autogen.sh
./configure --prefix={path-to-output}
make && make install
```

### Modify CMakeLists.txt

```CMake
INCLUDE_DIRECTORIES({path-to-output}/include)
TARGET_LINK_LIBRARIES({path-to-output}/lib)
```

### Execute command

```bash
mkdir build
cd build && cmake ..
# generate a binary called `proto_text` with path={path-to-proto-text}
```

### Generate tensorflow pb_text

```
# cd to the home to tensorflow

function bbbb() {
cmd="{path-to-proto-text}" # generated by previous process
file=$1
# to remove ./
file=${file:2}
${cmd} ${file}

cmd="/path/to/protoc"
SRC_DIR="./"
DST_DIR=`dirname ${file}`
${cmd} -I=$SRC_DIR --cpp_out="." ${file}
}

export -f bbbb

find . -name "*.proto" -exec bash -c 'bbbb "$0"' {} \;
```