waymo-research / waymo-open-dataset

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

Question about generating submission protos #306

Open arbaazkhan2 opened 3 years ago

arbaazkhan2 commented 3 years ago

Hi, I had a question about generating a proto;

According to an older reply the pseudo code for generating a proto was given as :

' for scenario in scenarios: my_predictions = predict(scenario) scenario_predictions = motion_submission_pb2.ChallengeScenarioPredictions() scenario_predictions.scenario_id = scenario.scenario_id

# Add a SingleObjectPrediction for each agent.
for agent in my_predictions:
  prediction = motion_submission_pb2.SingleObjectPrediction()
  prediction.object_id = agent.id

  # Add a ScoredTrajectory for each agent prediction.
  for trajectory in agent.predictions:
    scored_trajectory = motion_submission_pb2.ScoredTrajectory()
    scored_trajectory.confidence = trajectory.confidence

    # Subsample the prediction output to the required 2 Hz. 
    subsample_factor = 5
    count = 0
    for point in trajectory.points:
      count += 1
      if count == subsample_factor:
        scored_trajectory.trajectory.center_x.append(point.x)
        scored_trajectory.trajectory.center_y.append(point.y)
        count = 0
    prediction.trajectories.append(scored_trajectory)

  # Add the agent predictions to the ChallengeScenarioPredictions object.
  scenario_predictions.single_predictions.predictions.append(prediction)

# Add the scenario predictions to the submission.
submission.scenario_predictions.append(scenario_predictions)

` In my case my predictions for a given dataset file are of the shape : [num_batches x num_agents x 80 x 2]

My question was in the above code, what agents is the online checker looking for? Do we have to set num_agents to 128? or is it only those agents from the tracks_to_predict mask or is it agents from the samples_valid mask?

s-ettinger commented 3 years ago

Only agents listed in the tracks_to_predict field should be included in the submission proto. You will get an error if other agents are included in the predictions.

arbaazkhan2 commented 3 years ago

Thanks! Also follow up how do we actually save the proto? Is there a built in method to write the proto to disk?

s-ettinger commented 3 years ago

The protocol buffer object has a method called SerializeToString() that you can use to convert it to a binary string. You can then write this string to disk using python file I/O or whichever file library you are using.