protocol-buffers

False Boolean is not showing in proto3 Python

False Boolean is not showing in proto3 Python Question: I’m using protoBuffer 3 in python it is not showing bool fields correctly. entity_proto message Foo { string id = 1; bool active = 3; } Setting values in python. foo = entity_proto.Foo(id=’id-123′, active=True) print(foo) # id: id-123 # active: True # But if you set …

Total answers: 2

cannot import name 'string_int_label_map_pb2'

cannot import name 'string_int_label_map_pb2' Question: My goal is to run tensorflow object detection API and followed the steps in the installation. I install the tensorflow object detection API and protobuf. I have also added the path to protobuf. But the following error shoots up: ImportError: cannot import name ‘string_int_label_map_pb2’ Installed protobuf : %%bash cd models/research …

Total answers: 4

How can I use a gRPC "oneof" proto structure in python?

How can I use a gRPC "oneof" proto structure in python? Question: I am building a file storage client/server using python for the client, go for the server, along with gRPC. I have already successfully built the client in go and it works! I am trying to do the same in python now. Today, I …

Total answers: 1

Tensorflow: create tf.NodeDef() and set attributes

Tensorflow: create tf.NodeDef() and set attributes Question: I’m trying to create a new node and set its attributes. For example printing one of the graph nodes I see that its attributes are: attr { key: “T” value { type: DT_FLOAT } } I can create a node like: node = tf.NodeDef(name=’MyConstTensor’, op=’Const’, attr={‘value’: tf.AttrValue(tensor=tensor_proto), ‘dtype’: …

Total answers: 3

Dynamically Editing Pipeline Config for Tensorflow Object Detection

Dynamically Editing Pipeline Config for Tensorflow Object Detection Question: I’m using tensorflow object detection API, and I want to be able to edit config file dynamically in python, which looks like this. I thought of using protocol buffers library in python, but I’m not sure how to go about. model { ssd { num_classes: 1 …

Total answers: 6

How to generate python class files from protobuf

How to generate python class files from protobuf Question: I am trying to transfer large amounts of structured data from Java to Python. That includes many objects that are related to each other in some form or another. When I receive them in my Python code, it’s quiet ugly to work with the types that …

Total answers: 4

When would a Python float lose precision when cast to Protobuf/C++ float?

When would a Python float lose precision when cast to Protobuf/C++ float? Question: I’m interested in minimising the size of a protobuf message serialised from Python. Protobuf has floats (4 bytes) and doubles (8 bytes). Python has a float type that’s actually a C double, at least in CPython. My question is: given an instance …

Total answers: 3

protobuf MessageToJson removes fields with value 0

protobuf MessageToJson removes fields with value 0 Question: I’m writing a Python script that receives protobufs, converts them to json objects, and pushes them to another service. I use json.loads(MessageToJson(protobuf)) to convert the protobuf to a python dictionary object. Later I convert it back to json with json.dumps(dictionary). I have a proto with an optional …

Total answers: 3

Find enums listed in Python DESCRIPTOR for ProtoBuf

Find enums listed in Python DESCRIPTOR for ProtoBuf Question: I have received a Google ProtoBuf using Python, and am attempting to compare the value for an enum to a string representation of it. Based on this and this I should be able to use something like enum_values_by_name to get the info I need. However, all …

Total answers: 3

TensorFlow saving into/loading a graph from a file

TensorFlow saving into/loading a graph from a file Question: From what I’ve gathered so far, there are several different ways of dumping a TensorFlow graph into a file and then loading it into another program, but I haven’t been able to find clear examples/information on how they work. What I already know is this: Save …

Total answers: 2