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

https://github.com/yuanwenqing/tensorflow4j

A Java Library for Protobuf in TensorFlow and TensorFlow-Serving
https://github.com/yuanwenqing/tensorflow4j

jar java protobuf tensorflow tensorflow-serving tensorflow-serving-api

Last synced: about 1 month ago
JSON representation

A Java Library for Protobuf in TensorFlow and TensorFlow-Serving

Awesome Lists containing this project

README

          

# TensorFlow proto

Since [TensorFlow](https://github.com/tensorflow/tensorflow) and [TensorFlow-Serving](https://github.com/tensorflow/serving)
do not support official jars for their protobuf files right now,
we create this project to do it just for convenience and sharing.

## Usage

`tensorflow-proto` contains and compiles all protobuf files in TensorFlow,
and `serving-proto` does that for TensorFlow-Serving.
Since compiling of `serving-proto` imports protobuf from `tensorflow-proto`,
actually `serving-proto` contains all that `tensorflow-proto` has.
Therefore `serving-proto` is the only library you need when you want to do something with TensorFlow-Serving.

maven:

~~~xml


xyz.codemeans.tensorflow4j
tensorflow-proto
1.12.0


xyz.codemeans.tensorflow4j
serving-proto
1.12.0

~~~

gradle:

~~~groovy
implementation 'xyz.codemeans.tensorflow4j:tensorflow-proto:1.12.0'

implementation 'xyz.codemeans.tensorflow4j:serving-proto:1.12.0'
~~~

## Sync Protobuf Files

Clone those two projects,
checkout the latest version(or any other version you want),
and then run:

~~~bash
python sync_proto.py /path/to/tensorflow_project tensorflow-proto
python sync_proto.py /path/to/tensorflow_serving_project serving-proto
~~~

NOTE: a little BUGFIX must be done to `tensorflow/compiler/tf2xla/host_compute_metadata.proto`,
change `java_outer_classname` as below:

~~~proto
// option java_outer_classname = "Tf2XlaProtos";
option java_outer_classname = "HostComputeMetadataProtos";
~~~

## Build JAR Library

Requirements:

* protoc
* gradle
* protobuf lib

run:

~~~bash
gradle clean build
~~~

If you want to publish the built jars, you can run:

~~~bash
# publish to local maven repository (`~/.m2`)
gradle local
~~~

or

~~~bash
# config maven publishing and publish to nexus
gradle publish
~~~

## Version

Current version of TensorFlow and TensorFlow-Servng are both 1.12.0.

If you want to build library for another version, you MUST:

* checkout TensorFlow and TensorFlow-Serving source of exact version you want, then sync all proto files
* change version and publish setting in `build.gradle` for publishing somewhere