Drivestduio 代碼筆記與理解

Rigid Node: 表示 car或者trucks
Deformable Node : 表示一些 分布之外的 non-rigid 的運動物體, 比如遠處的行人等和Cyclist。

load_objects 會讀取每一個 dynamic objects 的 'bounding box’的信息,具體如下:
frame_instances 記錄了每一幀都有哪些 instance, 以及對應 每一幀 其 位姿信息等;
instances_info 包含每一幀 對于哪些 instance 是可見的。

1. 讀取 Bounding Box 的基本信息

邏輯是先遍歷場景的 instance, 然后 再每一個 instance 的信息。
## 存放每一幀 的instance 的pose
instances_pose = np.zeros((num_full_frames, num_instances, 4, 4))for k, v in instances_info.items():instances_model_types[int(k)] = OBJECT_CLASS_NODE_MAPPING[v["class_name"]]for frame_idx, obj_to_world, box_size in zip(v["frame_annotations"]["frame_idx"], v["frame_annotations"]["obj_to_world"], v["frame_annotations"]["box_size"]):# the first ego pose as the origin of the world coordinate system.obj_to_world = np.array(obj_to_world).reshape(4, 4)obj_to_world = np.linalg.inv(ego_to_world_start) @ obj_to_worldinstances_pose[frame_idx, int(k)] = np.array(obj_to_world)instances_size[frame_idx, int(k)] = np.array(box_size)

根據 per_frame_instance_mask來得到 每一幀對于哪些instance 是可見的。

  per_frame_instance_mask = np.zeros((num_full_frames, num_instances))for frame_idx, valid_instances in frame_instances.items():per_frame_instance_mask[int(frame_idx), valid_instances] = 1

2. 使用Bounding Box 的信息初始化高斯

這里需要介紹一個 dynamic vehicle 非常重要的坐標系,物體坐標系(Object系),其通常位于汽車的車輛中心。所以任何一幀的 Lidar 通過 w2o 矩陣可以將Lidar 點轉換到 canonical space, 完成對于多幀 Lidar 的聚集

將 Lidar 點 (世界坐標系下面的) 通過 轉化矩陣 w2o 轉換到 Object 坐標系下面 , 然后 根據 Bounding Box 的 Size 去保留 在 BBX 內部的點云,準備進行初始化。

 o2w = self.pixel_source.instances_pose[fi, ins_id]o_size = self.pixel_source.instances_size[ins_id]# convert the lidar points to the instance's coordinate systemw2o = torch.inverse(o2w)o_pts = transform_points(lidar_pts, w2o)# 將BBX 之外的點通過 Mask 濾除,這一步是在局部 Object 坐標系下面進行的mask = ((o_pts[:, 0] > -o_size[0] / 2)& (o_pts[:, 0] < o_size[0] / 2)& (o_pts[:, 1] > -o_size[1] / 2)& (o_pts[:, 1] < o_size[1] / 2)& (o_pts[:, 2] > -o_size[2] / 2)& (o_pts[:, 2] < o_size[2] / 2))valid_pts = o_pts[mask]valid_colors = self.lidar_source.colors[lidar_dict["lidar_mask"]][mask]
通過 比較 在 instances_pose 的pose (O2W系) 移動,僅僅對于 動態的 instance 進行保留 。

因為車輛的移動其實可以看成是 O2W坐標系的移動。 相當于車輛是靜止的,但是環境是運動的

if only_moving:# consider only the instances with non-zero flowslogger.info(f"Filtering out the instances with non-moving trajectories")new_instance_dict = {}for k, v in instance_dict.items():if v["num_pts"] > 0:  ## 僅僅考慮有點的 instance# flows = v["flows"]# if flows.norm(dim=-1).mean() > moving_thres:#     v.pop("flows")#     new_instance_dict[k] = v#     logger.info(f"Instance {k} has {v['num_pts']} lidar sample points")frame_info = self.pixel_source.per_frame_instance_mask[:, k]instances_pose = self.pixel_source.instances_pose[:, k]instances_trans = instances_pose[:, :3, 3]valid_trans = instances_trans[frame_info]traj_length = valid_trans[1:] - valid_trans[:-1]traj_length = torch.norm(traj_length, dim=-1).sum()if traj_length > traj_length_thres:new_instance_dict[k] = vlogger.info(f"Instance {k} has {v['num_pts']} lidar sample points")instance_dict = new_instance_dict

將所有幀的 Lidar Aggregated 到 Canonical Space 下面,如圖所示:
在這里插入圖片描述

靜態高斯的初始化

靜態的 高斯初始化 = Lidar_samples + 半球內的隨機采樣點。 隨機采樣點是 PVG 這篇文章所介紹的, 在 球內部 和 球外面進行均勻采樣。

Rigid 高斯的初始化

Canonical Space 累計的 點云進行 高斯的各項屬性的初始化, 讀取 點云的 坐標和顏色,然后進行初始化。 并記錄了 每個bbx 的大小以及 每個instance 在每一幀的可見性,分別用 self.instances_size self.instances_fv表示。

## (num_instances, 3) BBX 的大小self.instances_size = torch.stack(instances_size).to(self.device) # # (num_frame, num_instances) instance 在每一幀的可見性
self.instances_fv = torch.cat(instances_fv, dim=1).to(self.device) 

值得注意的是, Drivestudio 將每一幀的每一個 instance 的 BBX 的 的 pose 也作為參數去考慮優化:

 # (num_frame, num_instances, 4)  四元數self.instances_quats = Parameter(self.quat_act(instances_quats))# (num_frame, num_instances, 3) 平移
self.instances_trans = Parameter(instances_trans)             

高斯參數的優化器設置:

所有的 Rigid Nodes 會把放進一個 優化字典當中,然后一起優化,并不是每個 instance 去獨立的優化

Rigid 的每一個GS 都是像原始的 3DGS 一樣,配置 每一個屬性的 學習率去進行優化的。

groups.append({'params': params,'name': params_name,'lr': optim_cfg.lr,'eps': optim_cfg.eps,'weight_decay': optim_cfg.weight_decay})

groups 構建好之后,全部一起當作字典丟進 Adam 優化器去進行優化

self.optimizer = torch.optim.Adam(groups, lr=0.0, eps=1e-15)

Sky Model

Drivestudio 使用場景的 Environment map 來對于 天空的顏色進行建模. Sky 被建模成一個 長方體 cube, 然后使用基于光線方向(Opengl系)來在 environment cube 上進行紋理查詢。這個 environment map 雖然沒有任何網絡,但是其本身的參數也是需要被優化的。 對應的 Code 如下

class EnvLight(torch.nn.Module):def __init__(self,class_name: str,resolution=1024,device: torch.device = torch.device("cuda"),**kwargs):super().__init__()self.class_prefix = class_name + "#"self.device = deviceself.to_opengl = torch.tensor([[1, 0, 0], [0, 0, 1], [0, -1, 0]], dtype=torch.float32, device="cuda")## 需要被優化的 environment mapself.base = torch.nn.Parameter(0.5 * torch.ones(6, resolution, resolution, 3, requires_grad=True),)def forward(self, image_infos):l = image_infos["viewdirs"]l = (l.reshape(-1, 3) @ self.to_opengl.T).reshape(*l.shape)l = l.contiguous()prefix = l.shape[:-1]if len(prefix) != 3:  # reshape to [B, H, W, -1]l = l.reshape(1, 1, -1, l.shape[-1])light = dr.texture(self.base[None, ...], l, filter_mode='linear', boundary_mode='cube')light = light.view(*prefix, -1)return light

開始訓練:

針對每一個 Node 提取出場景的N 個動態對象高斯。 如果是 Rigid 物體的高斯,前面的代碼是采用 Object系存儲的,需要轉換到 World系,然后提取出來。

平移變化來分析:

首先我們有 frame_id 標記 我們訓練的是哪一幀,取出這一幀的所有 instance 對應的 旋轉和 rot_cur_frame 平移trans_cur_frame . 假設我們有M個動態點,將這M個動態點 和 應用在M個旋轉和平移向量上,同時得到了這個所有動態類別在場景frame_id對應的位置和坐標。

def transform_means(self, means: torch.Tensor) -> torch.Tensor:"""transform the means of instances to world spaceaccording to the pose at the current frame"""assert means.shape[0] == self.point_ids.shape[0], \"its a bug here, we need to pass the mask for points_ids"quats_cur_frame = self.instances_quats[self.cur_frame] # (num_instances, 4)rot_cur_frame = quat_to_rotmat(self.quat_act(quats_cur_frame))                                                          # (num_instances, 3, 3)## 求出每個點的旋轉rot_per_pts = rot_cur_frame[self.point_ids[..., 0]]        # (num_points, 3, 3)trans_cur_frame = self.instances_trans[self.cur_frame] # (num_instances, 3)## 求出每個點的平移trans_per_pts = trans_cur_frame[self.point_ids[..., 0]]# transform the means to world spacemeans = torch.bmm(rot_per_pts, means.unsqueeze(-1)).squeeze(-1) + trans_per_ptsreturn means

之后使用 gsplat作為渲染的框架,執行渲染, 這里的動態和靜態實際上都是轉換到 世界系的 高斯 然后一起渲染的。 為了渲染 動態物體,將場景高斯的 動態物體的 Opacity設置為0, 其他的屬性不用改變。

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/diannao/81045.shtml
繁體地址,請注明出處:http://hk.pswp.cn/diannao/81045.shtml
英文地址,請注明出處:http://en.pswp.cn/diannao/81045.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

《算法筆記》10.5小節——圖算法專題->最小生成樹 問題 E: Jungle Roads

題目描述 The Head Elder of the tropical island of Lagrishan has a problem. A burst of foreign aid money was spent on extra roads between villages some years ago. But the jungle overtakes roads relentlessly, so the large road network is too expensive to mai…

【音視頻】SDL簡介

官網&#xff1a;官網 文檔&#xff1a;文檔 SDL&#xff08;Simple DirectMedia Layer&#xff09;是一套開放源代碼的跨平臺多媒體開發庫&#xff0c;使用C語言寫成。SDL提供數種控制圖像、聲音、輸出入的函數&#xff0c;讓開發者只 要用相同或是相似的代碼就可以開發出跨多…

SpringBoot + SSE 實時異步流式推送

前言 在當今數字化時代&#xff0c;實時數據處理對于企業的決策和運營至關重要。許多業務場景需要及時響應數據庫中的數據變化&#xff0c;例如電商平臺實時更新庫存、金融系統實時監控交易數據等。 本文將詳細介紹如何通過Debezium捕獲數據庫變更事件&#xff0c;并利用Serv…

ADS1299模擬前端(AFE)代替芯片——LHE7909

在現代醫療科技的飛速發展中&#xff0c;精確的生物電勢測量設備變得越來越重要。領慧立芯推出的LHE7909&#xff0c;是一款專為心電圖&#xff08;ECG&#xff09;和其他生物電勢測量設計的低噪聲24位模數轉換器&#xff08;ADC&#xff09;&#xff0c;為醫療設備制造商提供了…

如何實現Redis和Mysql中數據雙寫一致性

一、引言 今天我們來聊聊一個在分布式系統中非常常見但又十分棘手的問題——Redis與MySQL之間的雙寫一致性。我們在項目中多多少少都遇到過類似的困擾&#xff0c;緩存是用Redis&#xff0c;數據庫是用MySQL&#xff0c;但如何確保兩者之間的數據一致性呢&#xff1f;接下來我…

面試篇 - Transformer前饋神經網絡(FFN)使用什么激活函數?

1. FFN結構分解 原始Transformer的FFN層 FFN(x) max(0, xW? b?)W? b? # 原始論文公式 輸入&#xff1a;自注意力層的輸出 x&#xff08;維度 d_model512&#xff09; 擴展層&#xff1a;xW? b?&#xff08;擴展為 d_ff2048&#xff09; 激活函數&#xff1a;Re…

基于Python Flask的深度學習電影評論情感分析可視化系統(2.0升級版,附源碼)

博主介紹&#xff1a;?IT徐師兄、7年大廠程序員經歷。全網粉絲15W、csdn博客專家、掘金/華為云//InfoQ等平臺優質作者、專注于Java技術領域和畢業項目實戰? &#x1f345;文末獲取源碼聯系&#x1f345; &#x1f447;&#x1f3fb; 精彩專欄推薦訂閱&#x1f447;&#x1f3…

前端vue2修改echarts字體為思源黑體-避免侵權-可以更換為任意字體統一管理

1.下載字體 npm install fontsource/noto-sans-sc 不知道為什么我從github上面下載的不好使&#xff0c;所以就用了npm的 2.引用字體 import fontsource/noto-sans-sc; 在入口文件-main.js中引用 3.設置echats模板樣式 import * as echarts from echarts; // 在import的后…

51c自動駕駛~合集37

我自己的原文哦~ https://blog.51cto.com/whaosoft/13878933 #DETR->DETR3D->Sparse4D 走向長時序稀疏3D目標檢測 一、DETR 圖1 DETR架構 DETR是第一篇將Transformer應用到目標檢測方向的算法。DETR是一個經典的Encoder-Decoder結構的算法&#xff0c;它的骨干網…

【MongoDB篇】MongoDB的集合操作!

目錄 引言第一節&#xff1a;集合的“誕生”——自動出現還是手動打造&#xff1f;&#x1f914;第二節&#xff1a;集合的“查閱”——看看這個數據庫里有哪些柜子&#xff1f;&#x1f4c2;&#x1f440;第三節&#xff1a;集合的“重命名”——給文件柜換個名字&#xff01;…

Goland終端PowerShell命令失效

Goland終端Terminal的PowerShell不能使用&#xff0c;明明windows上升級了PowerShell 7設置了配置文件&#xff0c;但是只能在windows終端下使用&#xff0c;goland終端下直接失效報錯&#xff0c;安裝升級PowerShell請看Windows11終端升級PowerShell7 - HashFlag - 博客園 問…

簡單分析自動駕駛發展現狀與挑戰

一、技術進展與市場滲透 技術分級與滲透率 當前量產乘用車的自動駕駛等級以L2為主&#xff08;滲透率約51%&#xff09;&#xff0c;L3級處于初步落地階段&#xff08;滲透率約20%&#xff09;&#xff0c;而L4級仍處于測試和示范運營階段&#xff08;滲透率約11%&#xff09;2…

【C++類和數據抽象】消息處理示例(1):從設計模式到實戰應用

目錄 一、數據抽象概述 二、消息處理的核心概念 2.1 什么是消息處理&#xff1f; 2.2 消息處理的核心目標 三、基于設計模式的消息處理實現 3.1 觀察者模式&#xff08;Observer Pattern&#xff09; 3.2 命令模式&#xff08;Command Pattern&#xff09; 四、實戰場景…

【統計方法】交叉驗證:Resampling, nested 交叉驗證等策略 【含R語言】

Resampling (重采樣方法) 重采樣方法是從訓練數據中反復抽取樣本&#xff0c;并在每個&#xff08;重新&#xff09;樣本上重新調整模型&#xff0c;以獲得關于擬合模型的附加信息的技術。 兩種主要的重采樣方法 Cross-Validation (CV) 交叉驗證 &#xff1a; 用于估計測試誤…

常見的 CSS 知識點整理

1. 盒模型&#xff08;Box Model&#xff09;是什么&#xff1f;標準盒模型和 IE 盒模型的區別&#xff1f; 答案&#xff1a; CSS 盒模型將元素視為一個盒子&#xff0c;由內容&#xff08;content&#xff09;、內邊距&#xff08;padding&#xff09;、邊框&#xff08;bor…

Educational Codeforces Round 178 div2(題解ABCDE)

A. Three Decks #1.由于最后三個數會相等&#xff0c;提前算出來和&#xff0c;%3判斷&#xff0c;再判前兩個數是否大于 #include<iostream> #include<vector> #include<stdio.h> #include<map> #include<string> #include<algorithm> #…

如何創建一個導入模板?全流程圖文解析

先去找到系統內可以上傳東西的按鈕 把你的模板上傳上去,找到對應的fileName 圖里的文字寫錯了,是復制粘貼"filePath"到URL才能下載

通信原理第七版與第六版區別附pdf

介紹 我用夸克網盤分享了「通信原理 第7版》樊昌信」&#xff0c;鏈接&#xff1a;https://pan.quark.cn/s/be7c5af4cdce 《通信原理&#xff08;第7版&#xff09;》是在第6版的基礎上&#xff0c;為了適應當前通信技術發展和教學需求&#xff0c;并吸取了數十所院校教師的反…

Mysql唯一性約束

唯一性約束&#xff08;Unique Constraint&#xff09;是數據庫設計中用于保證表中某一列或多列組合的值具有唯一性的一種規則。它可以防止在指定列中插入重復的數據&#xff0c;有助于維護數據的完整性和準確性。下面從幾個方面為你詳細解釋 作用 確保數據準確性&#xff1a…

測試基礎筆記第十六天

提示&#xff1a;文章寫完后&#xff0c;目錄可以自動生成&#xff0c;如何生成可參考右邊的幫助文檔 文章目錄 一、UI自動化介紹1.認識UI自動化測試2.實施UI自動化測試前置條件3.UI自動化測試執行時機4.UI自動化測試核心作用和劣勢 二、認識Web自動化測試工具-Selenium021.Sel…