Waymo数据集介绍(部分下载,仅用于学习)

2023-11-01 02:30

本文主要是介绍Waymo数据集介绍(部分下载,仅用于学习),希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

waymo提供了两种数据集,motion与perception两种,请注意,本篇为Perception Dataset v1.2Motion Dataset v1.1版本

其中motion是鸟瞰图,官网中有介绍,主要用于轨迹预测之类的任务

perception主要用于目标检测跟踪之类的任务,是第一视角,有相机和雷达信息,并且在github上有公开的读取数据方法,另外,在读取perception数据时需要安装waymo-open-dataset-tf这个库,安装不上请用清华源,具体请按照官方quick_start教程,另外github有许多已经集成许多功能的代码,搜索waymo就有。

quick_start:

waymo-open-dataset/quick_start.md at master · waymo-research/waymo-open-dataset · GitHub

 而motion读取不需要这些,主只需要安装tensorflow以及一些必要的库就行即可

import math
import os
import uuid
import timefrom matplotlib import cm
import matplotlib.animation as animation
import matplotlib.pyplot as pltimport numpy as np
from IPython.display import HTML
import itertools
import tensorflow as tffrom google.protobuf import text_format
from waymo_open_dataset.metrics.ops import py_metrics_ops
from waymo_open_dataset.metrics.python import config_util_py as config_util
from waymo_open_dataset.protos import motion_metrics_pb2# Example field definition
roadgraph_features = {'roadgraph_samples/dir':tf.io.FixedLenFeature([20000, 3], tf.float32, default_value=None),'roadgraph_samples/id':tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),'roadgraph_samples/type':tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),'roadgraph_samples/valid':tf.io.FixedLenFeature([20000, 1], tf.int64, default_value=None),'roadgraph_samples/xyz':tf.io.FixedLenFeature([20000, 3], tf.float32, default_value=None),
}# Features of other agents.
state_features = {'state/id':tf.io.FixedLenFeature([128], tf.float32, default_value=None),'state/type':tf.io.FixedLenFeature([128], tf.float32, default_value=None),'state/is_sdc':tf.io.FixedLenFeature([128], tf.int64, default_value=None),'state/tracks_to_predict':tf.io.FixedLenFeature([128], tf.int64, default_value=None),'state/current/bbox_yaw':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/height':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/length':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/timestamp_micros':tf.io.FixedLenFeature([128, 1], tf.int64, default_value=None),'state/current/valid':tf.io.FixedLenFeature([128, 1], tf.int64, default_value=None),'state/current/vel_yaw':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/velocity_x':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/velocity_y':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/width':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/x':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/y':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/current/z':tf.io.FixedLenFeature([128, 1], tf.float32, default_value=None),'state/future/bbox_yaw':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/height':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/length':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/timestamp_micros':tf.io.FixedLenFeature([128, 80], tf.int64, default_value=None),'state/future/valid':tf.io.FixedLenFeature([128, 80], tf.int64, default_value=None),'state/future/vel_yaw':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/velocity_x':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/velocity_y':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/width':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/x':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/y':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/future/z':tf.io.FixedLenFeature([128, 80], tf.float32, default_value=None),'state/past/bbox_yaw':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/height':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/length':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/timestamp_micros':tf.io.FixedLenFeature([128, 10], tf.int64, default_value=None),'state/past/valid':tf.io.FixedLenFeature([128, 10], tf.int64, default_value=None),'state/past/vel_yaw':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/velocity_x':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/velocity_y':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/width':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/x':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/y':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),'state/past/z':tf.io.FixedLenFeature([128, 10], tf.float32, default_value=None),
}traffic_light_features = {'traffic_light_state/current/state':tf.io.FixedLenFeature([1, 16], tf.int64, default_value=None),'traffic_light_state/current/valid':tf.io.FixedLenFeature([1, 16], tf.int64, default_value=None),'traffic_light_state/current/x':tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),'traffic_light_state/current/y':tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),'traffic_light_state/current/z':tf.io.FixedLenFeature([1, 16], tf.float32, default_value=None),'traffic_light_state/past/state':tf.io.FixedLenFeature([10, 16], tf.int64, default_value=None),'traffic_light_state/past/valid':tf.io.FixedLenFeature([10, 16], tf.int64, default_value=None),'traffic_light_state/past/x':tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),'traffic_light_state/past/y':tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),'traffic_light_state/past/z':tf.io.FixedLenFeature([10, 16], tf.float32, default_value=None),
}
dir = '文件位置'
features_description = {}
features_description.update(roadgraph_features)
features_description.update(state_features)
features_description.update(traffic_light_features)dataset = tf.data.TFRecordDataset(dir, compression_type='')
data = next(dataset.as_numpy_iterator())
parsed = tf.io.parse_single_example(data, features_description)def create_figure_and_axes(size_pixels):"""Initializes a unique figure and axes for plotting."""fig, ax = plt.subplots(1, 1, num=uuid.uuid4())# Sets output image to pixel resolution.dpi = 100size_inches = size_pixels / dpifig.set_size_inches([size_inches, size_inches])fig.set_dpi(dpi)fig.set_facecolor('white')ax.set_facecolor('white')ax.xaxis.label.set_color('black')ax.tick_params(axis='x', colors='black')ax.yaxis.label.set_color('black')ax.tick_params(axis='y', colors='black')fig.set_tight_layout(True)ax.grid(False)return fig, axdef fig_canvas_image(fig):"""Returns a [H, W, 3] uint8 np.array image from fig.canvas.tostring_rgb()."""# Just enough margin in the figure to display xticks and yticks.fig.subplots_adjust(left=0.08, bottom=0.08, right=0.98, top=0.98, wspace=0.0, hspace=0.0)fig.canvas.draw()data = np.frombuffer(fig.canvas.tostring_rgb(), dtype=np.uint8)return data.reshape(fig.canvas.get_width_height()[::-1] + (3,))def get_colormap(num_agents):"""Compute a color map array of shape [num_agents, 4]."""colors = cm.get_cmap('jet', num_agents)colors = colors(range(num_agents))np.random.shuffle(colors)return colorsdef get_viewport(all_states, all_states_mask):"""Gets the region containing the data.Args:all_states: states of agents as an array of shape [num_agents, num_steps,2].all_states_mask: binary mask of shape [num_agents, num_steps] for`all_states`.Returns:center_y: float. y coordinate for center of data.center_x: float. x coordinate for center of data.width: float. Width of data."""valid_states = all_states[all_states_mask]all_y = valid_states[..., 1]all_x = valid_states[..., 0]center_y = (np.max(all_y) + np.min(all_y)) / 2center_x = (np.max(all_x) + np.min(all_x)) / 2range_y = np.ptp(all_y)range_x = np.ptp(all_x)width = max(range_y, range_x)return center_y, center_x, widthdef visualize_one_step(states,mask,roadgraph,title,center_y,center_x,width,color_map,size_pixels=1000):"""Generate visualization for a single step."""# Create figure and axes.fig, ax = create_figure_and_axes(size_pixels=size_pixels)# Plot roadgraph.rg_pts = roadgraph[:, :2].Tax.plot(rg_pts[0, :], rg_pts[1, :], 'k.', alpha=1, ms=2)masked_x = states[:, 0][mask]masked_y = states[:, 1][mask]colors = color_map[mask]# Plot agent current position.ax.scatter(masked_x,masked_y,marker='o',linewidths=3,color=colors,)# Title.ax.set_title(title)# Set axes.  Should be at least 10m on a side and cover 160% of agents.size = max(10, width * 1.0)ax.axis([-size / 2 + center_x, size / 2 + center_x, -size / 2 + center_y,size / 2 + center_y])ax.set_aspect('equal')image = fig_canvas_image(fig)plt.close(fig)return imagedef visualize_all_agents_smooth(decoded_example,size_pixels=1000,
):"""Visualizes all agent predicted trajectories in a serie of images.Args:decoded_example: Dictionary containing agent info about all modeled agents.size_pixels: The size in pixels of the output image.Returns:T of [H, W, 3] uint8 np.arrays of the drawn matplotlib's figure canvas."""# [num_agents, num_past_steps, 2] float32.past_states = tf.stack([decoded_example['state/past/x'], decoded_example['state/past/y']],-1).numpy()past_states_mask = decoded_example['state/past/valid'].numpy() > 0.0# [num_agents, 1, 2] float32.current_states = tf.stack([decoded_example['state/current/x'], decoded_example['state/current/y']],-1).numpy()current_states_mask = decoded_example['state/current/valid'].numpy() > 0.0# [num_agents, num_future_steps, 2] float32.future_states = tf.stack([decoded_example['state/future/x'], decoded_example['state/future/y']],-1).numpy()future_states_mask = decoded_example['state/future/valid'].numpy() > 0.0# [num_points, 3] float32.roadgraph_xyz = decoded_example['roadgraph_samples/xyz'].numpy()num_agents, num_past_steps, _ = past_states.shapenum_future_steps = future_states.shape[1]color_map = get_colormap(num_agents)# [num_agens, num_past_steps + 1 + num_future_steps, depth] float32.all_states = np.concatenate([past_states, current_states, future_states], 1)# [num_agens, num_past_steps + 1 + num_future_steps] float32.all_states_mask = np.concatenate([past_states_mask, current_states_mask, future_states_mask], 1)center_y, center_x, width = get_viewport(all_states, all_states_mask)images = []# Generate images from past time steps.for i, (s, m) in enumerate(zip(np.split(past_states, num_past_steps, 1),np.split(past_states_mask, num_past_steps, 1))):im = visualize_one_step(s[:, 0], m[:, 0], roadgraph_xyz,'past: %d' % (num_past_steps - i), center_y,center_x, width, color_map, size_pixels)images.append(im)# Generate one image for the current time step.s = current_statesm = current_states_maskim = visualize_one_step(s[:, 0], m[:, 0], roadgraph_xyz, 'current', center_y,center_x, width, color_map, size_pixels)images.append(im)# Generate images from future time steps.for i, (s, m) in enumerate(zip(np.split(future_states, num_future_steps, 1),np.split(future_states_mask, num_future_steps, 1))):im = visualize_one_step(s[:, 0], m[:, 0], roadgraph_xyz,'future: %d' % (i + 1), center_y, center_x, width,color_map, size_pixels)images.append(im)return imagesimages = visualize_all_agents_smooth(parsed)def create_animation(images):""" Creates a Matplotlib animation of the given images.Args:images: A list of numpy arrays representing the images.Returns:A matplotlib.animation.Animation.Usage:anim = create_animation(images)anim.save('/tmp/animation.avi')HTML(anim.to_html5_video())"""plt.ioff()fig, ax = plt.subplots()dpi = 100size_inches = 1000 / dpifig.set_size_inches([size_inches, size_inches])plt.ion()def animate_func(i):ax.imshow(images[i])ax.set_xticks([])ax.set_yticks([])ax.grid('off')anim = animation.FuncAnimation(fig, animate_func, frames=len(images) // 2, interval=100)plt.close(fig)return animanim = create_animation(images[::5])
HTML(anim.to_html5_video())

官方给的教程,生成的是一个动画,当然,这些动画没什么用,只需要里面的数据。上面代码主要的读取数据就是这一句,它包含了一个文件的信息,可以debug看一下,包含了许多属性,具体参见此处https://waymo.com/open/data/motion/tfexample,数据中有许多标注的为-1,这些数据没什么用

parsed = tf.io.parse_single_example(data, features_description)

 完整版数据集下载请前往官网下载 https://waymo.com/open/download/

此处只提供小部分用于学习,如有侵权,请及时联系删除

 百度云链接:

perception(v1.2)里面只提供了train的第一个文件

链接:https://pan.baidu.com/s/1PfPnVsWs7H47fi015vKL-g 
提取码:1lzk

motion(v1.1)提供train valid test里面的第一个文件

链接:https://pan.baidu.com/s/1RX4ISe23rkO-7OXM3imFpg 
提取码:frb9

这篇关于Waymo数据集介绍(部分下载,仅用于学习)的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/319849

相关文章

MySQL 删除数据详解(最新整理)

《MySQL删除数据详解(最新整理)》:本文主要介绍MySQL删除数据的相关知识,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录一、前言二、mysql 中的三种删除方式1.DELETE语句✅ 基本语法: 示例:2.TRUNCATE语句✅ 基本语

使用Python实现可恢复式多线程下载器

《使用Python实现可恢复式多线程下载器》在数字时代,大文件下载已成为日常操作,本文将手把手教你用Python打造专业级下载器,实现断点续传,多线程加速,速度限制等功能,感兴趣的小伙伴可以了解下... 目录一、智能续传:从崩溃边缘抢救进度二、多线程加速:榨干网络带宽三、速度控制:做网络的好邻居四、终端交互

Python中win32包的安装及常见用途介绍

《Python中win32包的安装及常见用途介绍》在Windows环境下,PythonWin32模块通常随Python安装包一起安装,:本文主要介绍Python中win32包的安装及常见用途的相关... 目录前言主要组件安装方法常见用途1. 操作Windows注册表2. 操作Windows服务3. 窗口操作

MyBatisPlus如何优化千万级数据的CRUD

《MyBatisPlus如何优化千万级数据的CRUD》最近负责的一个项目,数据库表量级破千万,每次执行CRUD都像走钢丝,稍有不慎就引起数据库报警,本文就结合这个项目的实战经验,聊聊MyBatisPl... 目录背景一、MyBATis Plus 简介二、千万级数据的挑战三、优化 CRUD 的关键策略1. 查

python实现对数据公钥加密与私钥解密

《python实现对数据公钥加密与私钥解密》这篇文章主要为大家详细介绍了如何使用python实现对数据公钥加密与私钥解密,文中的示例代码讲解详细,感兴趣的小伙伴可以跟随小编一起学习一下... 目录公钥私钥的生成使用公钥加密使用私钥解密公钥私钥的生成这一部分,使用python生成公钥与私钥,然后保存在两个文

mysql中的数据目录用法及说明

《mysql中的数据目录用法及说明》:本文主要介绍mysql中的数据目录用法及说明,具有很好的参考价值,希望对大家有所帮助,如有错误或未考虑完全的地方,望不吝赐教... 目录1、背景2、版本3、数据目录4、总结1、背景安装mysql之后,在安装目录下会有一个data目录,我们创建的数据库、创建的表、插入的

c++中的set容器介绍及操作大全

《c++中的set容器介绍及操作大全》:本文主要介绍c++中的set容器介绍及操作大全,本文通过实例代码给大家介绍的非常详细,对大家的学习或工作具有一定的参考借鉴价值,需要的朋友参考下吧... 目录​​一、核心特性​​️ ​​二、基本操作​​​​1. 初始化与赋值​​​​2. 增删查操作​​​​3. 遍历方

Navicat数据表的数据添加,删除及使用sql完成数据的添加过程

《Navicat数据表的数据添加,删除及使用sql完成数据的添加过程》:本文主要介绍Navicat数据表的数据添加,删除及使用sql完成数据的添加过程,具有很好的参考价值,希望对大家有所帮助,如有... 目录Navicat数据表数据添加,删除及使用sql完成数据添加选中操作的表则出现如下界面,查看左下角从左

SpringBoot中4种数据水平分片策略

《SpringBoot中4种数据水平分片策略》数据水平分片作为一种水平扩展策略,通过将数据分散到多个物理节点上,有效解决了存储容量和性能瓶颈问题,下面小编就来和大家分享4种数据分片策略吧... 目录一、前言二、哈希分片2.1 原理2.2 SpringBoot实现2.3 优缺点分析2.4 适用场景三、范围分片

Redis分片集群、数据读写规则问题小结

《Redis分片集群、数据读写规则问题小结》本文介绍了Redis分片集群的原理,通过数据分片和哈希槽机制解决单机内存限制与写瓶颈问题,实现分布式存储和高并发处理,但存在通信开销大、维护复杂及对事务支持... 目录一、分片集群解android决的问题二、分片集群图解 分片集群特征如何解决的上述问题?(与哨兵模