waymo-research / waymo-open-dataset

Waymo Open Dataset
https://www.waymo.com/open
Other
2.69k stars 610 forks source link

Waymo dataset protobuf dataformat issue #509

Open inf19150 opened 2 years ago

inf19150 commented 2 years ago

I wanted to parse the polyline of a RoadLine (as part of the map-data), which is declared as .proto-File.

I'm using the waymo-open-dataset-tf-2-5-0 dependency in python to access and load a particular object within scenario-format. My parsing is similar to this (taken from tutorial notebook):

FILENAME = '/content/waymo-od/tutorial/frames' dataset = tf.data.TFRecordDataset(FILENAME, compression_type='') for data in dataset: frame = open_dataset.Frame() frame.ParseFromString(bytearray(data.numpy())) break

Unfortunately, the polyline object is empty / filled with 0-Tripels for (x, y, z) image whereas static data (e.g. Enum-Declaration of RoadLine-Message in proto) gets parsed without a problem image

Has anybody experienced similar issues, related to scenario / protobuf-Format.

s-ettinger commented 2 years ago

In your sample code you are parsing the string into a Frame proto. The Frame proto does not contain map information. Currently, only the motion dataset contains map information which is stored as Scenario protos.

inf19150 commented 2 years ago

In your sample code you are parsing the string into a Frame proto. The Frame proto does not contain map information. Currently, only the motion dataset contains map information which is stored as Scenario protos.

The snippet I posted only outlines the methodology, in the actual code I am using open_dataset.RoadLine() for instance, which should be referring to map.proto

inf19150 commented 2 years ago

Given the function

def parse_proto_objects(path_to_waymo: str, obj) -> list:
    """
    Parses objects of protobuf-declaration within waymo-dataset

    :param path_to_waymo: str of path, where *.tfrecord-files are placed
    :param obj: class-type of desired objects returned by this function within waymo_open_dataset.protos
    :return list of desired objects within all filed tfrecord-files
    """
    DO_DEBUG_PRINTS=True
    parsed_objects = []
    for f in os.listdir(path_to_waymo):
        dataset = tf.data.TFRecordDataset(
            os.path.join(path_to_waymo, f), compression_type=""
        )
        for data in dataset:
            parsed_object = obj()
            parsed_object.ParseFromString(bytes(data.numpy()))
            # print(parsed_object)
            parsed_objects.append(parsed_object)
            if DO_DEBUG_PRINTS:
                for item in parsed_object.polyline:
                    print(item)
    return parsed_objects

Calling parse_proto_objects in such a snippet

from plai_waymo_motion_plugin.waymo.waymo_helper import parse_proto_objects
from waymo_open_dataset.protos import map_pb2

PATH = "./waymo_dataset_raw_scenario/" # scenario proto files stored in this dir
obj = parse_proto_objects(PATH, map_pb2.RoadLine)

will neither return useful values as debug-prints, nor debugging after parsed_object.ParseFromString(...) at different iteration-positions will give me values other than (0, 0, 0).

image

s-ettinger commented 2 years ago

The TfRecord files contain serialized strings of Scenario protos. I believe you need to pass your function the Scenario proto type defined here: https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/protos/scenario.proto

s-ettinger commented 2 years ago

The TfRecord files contain serialized strings of Scenario protos. I believe you need to pass your function the Scenario proto type defined here: https://github.com/waymo-research/waymo-open-dataset/blob/master/waymo_open_dataset/protos/scenario.proto .

On Wed, Jun 22, 2022 at 4:39 AM inf19150 @.***> wrote:

Given the function

def parse_proto_objects(path_to_waymo: str, obj) -> list: """ Parses objects of protobuf-declaration within waymo-dataset

:param path_to_waymo: str of path, where *.tfrecord-files are placed
:param obj: class-type of desired objects returned by this function within waymo_open_dataset.protos
:return list of desired objects within all filed tfrecord-files
"""
DO_DEBUG_PRINTS=True
parsed_objects = []
for f in os.listdir(path_to_waymo):
    dataset = tf.data.TFRecordDataset(
        os.path.join(path_to_waymo, f), compression_type=""
    )
    for data in dataset:
        parsed_object = obj()
        parsed_object.ParseFromString(bytes(data.numpy()))
        # print(parsed_object)
        parsed_objects.append(parsed_object)
        if DO_DEBUG_PRINTS:
            for item in parsed_object.polyline:
                print(item)
return parsed_objects

Calling parse_proto_objects in such a snippet

from plai_waymo_motion_plugin.waymo.waymo_helper import parse_proto_objects from waymo_open_dataset.protos import map_pb2

PATH = "./waymo_dataset_raw_scenario/" #.tfexample files stored in this dir obj = parse_proto_objects(PATH, map_pb2.RoadLine)

will neither return useful values as debug-prints, nor debugging after parsed_object.ParseFromString(...) at different iteration-positions will give me values other than (0, 0, 0).

[image: image] https://user-images.githubusercontent.com/72318314/175019880-838f62e3-9219-42a6-9817-b4a8d1c2eaed.png

— Reply to this email directly, view it on GitHub https://github.com/waymo-research/waymo-open-dataset/issues/509#issuecomment-1162991209, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATYRUOY2NA2KSJJLXJKTHDLVQL3QPANCNFSM5YFPLCTQ . You are receiving this because you commented.Message ID: @.***>