从零理解WidthFormer原理和源码1-极坐标的3D位置编码

简介

在这里插入图片描述
WidthFormer是一种轻量级且易于部署的BEV变换方法,它使用单层transformer解码器来计算BEV表示。除此之外,还提出了参考位置编码(RefPE),这是一种新的用于3D对象检测的位置编码机制,以辅助WidthFormer的视图转换,重点来啦!它还可以用于以即插即用的方式提高稀疏3D检测器的性能。

PETR类型的极坐标位置编码

视锥生成

函数源码和原理解析

    def create_frustum(self):
        # make grid in image plane
        ogfH, ogfW = self.data_config['input_size']#原始图像的高度和宽度 (256,704)
        fH, fW = ogfH // self.downsample, ogfW // self.downsample# feature图高度和宽度 (16,44)

        if not self.LID: #均匀分布
            ds = torch.arange(*self.grid_config['dbound'], dtype=torch.float).view(-1, 1, 1).expand(-1, fH, fW) # dp in 3d grid:(59,16,44) 59 depths in gridsize(16,44)
        else:#深度值不是均匀分布
            # reference: PETR
            depth_start, depth_end, depth_step = self.grid_config['dbound']
            depth_num = (depth_end - depth_start) // depth_step
            index = torch.arange(start=0, end=depth_num, step=1).float()
            index_1 = index + 1
            bin_size = (depth_end + 1 - depth_start) / (depth_num * (1. + depth_num))
            ds = depth_start + bin_size * index * index_1
            ds = ds.view(-1, 1, 1).expand(-1, fH, fW)
        D, _, _ = ds.shape
        xs = torch.linspace(0, ogfW - 1, fW, dtype=torch.float).view(1, 1, fW).expand(D, fH, fW)# pixel_x in 3d grid
        ys = torch.linspace(0, ogfH - 1, fH, dtype=torch.float).view(1, fH, 1).expand(D, fH, fW)# pixel_y in 3d grid

        # D x H x W x 3 

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-18 22:10:03       49 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-18 22:10:03       53 阅读
  3. 在Django里面运行非项目文件

    2024-07-18 22:10:03       42 阅读
  4. Python语言-面向对象

    2024-07-18 22:10:03       53 阅读

热门阅读

  1. PTA - Hello World

    2024-07-18 22:10:03       16 阅读
  2. 项目实战问题

    2024-07-18 22:10:03       16 阅读
  3. python数据挖掘---机器学习模型

    2024-07-18 22:10:03       16 阅读
  4. 240717.学习日志——51单片机C语言版学习总结

    2024-07-18 22:10:03       18 阅读
  5. 西南大学学报社会科学版

    2024-07-18 22:10:03       19 阅读
  6. 思维导图各图使用场景

    2024-07-18 22:10:03       20 阅读
  7. Web开发-LinuxGit基础1-本地-git配置文件

    2024-07-18 22:10:03       17 阅读
  8. C语言 合并2个有序链表

    2024-07-18 22:10:03       18 阅读
  9. SVN泄露

    2024-07-18 22:10:03       18 阅读
  10. 【ZMH的学习笔记】修饰符类型

    2024-07-18 22:10:03       18 阅读
  11. .Net C# Using 关键字的介绍与使用

    2024-07-18 22:10:03       18 阅读
  12. 前端实现将多个页面导出为pdf(分页)

    2024-07-18 22:10:03       16 阅读