bytedeco / javacpp-presets

The missing Java distribution of native C++ libraries
Other
2.63k stars 731 forks source link

Tensorflow's protobuf : compile .proto files and inlcude the generated class files in jar? #240

Open thammegowda opened 8 years ago

thammegowda commented 8 years ago

Is there a smart way to include the protocol buffer java counterparts into build?

I am having hard time deserializing protobuffers with c++ classes via JavaCPP.

Java classes of framework can be obtained by protoc

protoc  --java_out=protogen ./tensorflow/core/framework/*.proto

problem with this approach is ofcourse these classes are disconnected from core/framework. Is there a smart way to swap/proxy the C++ equivalents with the classes generated by protoc ?

saudet commented 8 years ago

Not that I know of. There isn't anything else that comes close to JavaCPP when it comes to bridging the gap between Java and C++, so it's unlikely anyone has bothered to do anything about protobuf either...

thammegowda commented 8 years ago

Thanks for the reply. Javacpp is great and i also did not find anything else that comes closer to this.

Did any of you tried deserializing protobuf models with this library? If yes, can you please point me to an example.

I tried, but then I found that we need c++ protobuf library in place to deserialize the model files to c++ classes. Else we need models classes in pure Java to use Java protobuf library.

Help Needed.

saudet commented 8 years ago

Either we're going to need both the C++ and Java versions of protobuf, that is to serialize from C++, and then deserialize from Java. That's just how it works.