首页 > 其他分享 >lss

lss

时间:2023-06-02 18:13:56浏览次数:22  
标签:10 5.0000 10.0000 6.6667 lss 16.6667 0.0000

    def create_frustum(self):
        # make grid in image plane
        ogfH, ogfW = self.data_aug_conf['final_dim'] #ogfH:128 ogfW:352
        fH, fW = ogfH // self.downsample, ogfW // self.downsample #downsample16  fH:8  fW:22
        #shape tmp(41) 4,5,6,...,44                       #grid_conf['dbound'] [4,45,1]
        tmp = torch.arange(*self.grid_conf['dbound'], dtype=torch.float)
        #ds [41, 8, 22]
        ds = torch.arange(*self.grid_conf['dbound'], dtype=torch.float).view(-1, 1, 1).expand(-1, fH, fW)
        D, _, _ = ds.shape #D=41

        #tmp_xs[22]    ogfW:352  fW:22  fH:8  fW:22           (351/21=16.7143)
        tmp_xs = torch.linspace(0, ogfW - 1, fW, dtype=torch.float)
        #tmp_ys[8]            ogfH:128  fH:8  (127/7=18.1429)
        tmp_ys = torch.linspace(0, ogfH - 1, fH, dtype=torch.float)

        # xs, ys [41, 8, 22]
        xs = torch.linspace(0, ogfW - 1, fW, dtype=torch.float).view(1, 1, fW).expand(D, fH, fW)
        ys = torch.linspace(0, ogfH - 1, fH, dtype=torch.float).view(1, fH, 1).expand(D, fH, fW)

        # D x H x W x 3   [41, 8, 22, 3]
        frustum = torch.stack((xs, ys, ds), -1)
        return nn.Parameter(frustum, requires_grad=False)

test_create_frustum.py

import torch

downsample = 3
ogfH = 21
ogfW = 36

#fH=7  fW=12
fH, fW = ogfH // downsample, ogfW // downsample
#ds[2,7,12]                                      ds[9,7,12]      #*[5, 50, 5]
ds = torch.arange(*[5, 15, 5], dtype=torch.float).view(-1, 1, 1).expand(-1, fH, fW)
#D=2
D, _, _ = ds.shape

#tmp_xs[12]    ogfW:36  fW:12  fH:7            (35/11=3.1818)
tmp_xs = torch.linspace(0, ogfW - 1, fW, dtype=torch.float)
#tmp_ys[7]            ogfH:21  fH:7  (20/6=3.333)
tmp_ys = torch.linspace(0, ogfH - 1, fH, dtype=torch.float)

# xs, ys [2, 7, 12]
xs = torch.linspace(0, ogfW - 1, fW, dtype=torch.float).view(1, 1, fW).expand(D, fH, fW)
ys = torch.linspace(0, ogfH - 1, fH, dtype=torch.float).view(1, fH, 1).expand(D, fH, fW)

# D x H x W x 3   [2, 7, 12, 3]
frustum = torch.stack((xs, ys, ds), -1)

print("==============>>>>>>>>>>>>>>>xs")
print(xs)

print("==============>>>>>>>>>>>>>>>ys")
print(ys)

print("==============>>>>>>>>>>>>>>>ds")
print(ds)

print("==============>>>>>>>>>>>>>>>frustum")
print(frustum)
/media/algo/data_1/software/anconda_install/envs/pytorch1.7.0_general/bin/python3 /media/algo/data_1/everyday/20230602/test_create_frustum.py
==============>>>>>>>>>>>>>>>xs
tensor([[[ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000]],

        [[ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000],
         [ 0.0000,  3.1818,  6.3636,  9.5455, 12.7273, 15.9091, 19.0909,
          22.2727, 25.4545, 28.6364, 31.8182, 35.0000]]])
==============>>>>>>>>>>>>>>>ys
tensor([[[ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,
           0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 3.3333,  3.3333,  3.3333,  3.3333,  3.3333,  3.3333,  3.3333,
           3.3333,  3.3333,  3.3333,  3.3333,  3.3333],
         [ 6.6667,  6.6667,  6.6667,  6.6667,  6.6667,  6.6667,  6.6667,
           6.6667,  6.6667,  6.6667,  6.6667,  6.6667],
         [10.0000, 10.0000, 10.0000, 10.0000, 10.0000, 10.0000, 10.0000,
          10.0000, 10.0000, 10.0000, 10.0000, 10.0000],
         [13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333,
          13.3333, 13.3333, 13.3333, 13.3333, 13.3333],
         [16.6667, 16.6667, 16.6667, 16.6667, 16.6667, 16.6667, 16.6667,
          16.6667, 16.6667, 16.6667, 16.6667, 16.6667],
         [20.0000, 20.0000, 20.0000, 20.0000, 20.0000, 20.0000, 20.0000,
          20.0000, 20.0000, 20.0000, 20.0000, 20.0000]],

        [[ 0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,  0.0000,
           0.0000,  0.0000,  0.0000,  0.0000,  0.0000],
         [ 3.3333,  3.3333,  3.3333,  3.3333,  3.3333,  3.3333,  3.3333,
           3.3333,  3.3333,  3.3333,  3.3333,  3.3333],
         [ 6.6667,  6.6667,  6.6667,  6.6667,  6.6667,  6.6667,  6.6667,
           6.6667,  6.6667,  6.6667,  6.6667,  6.6667],
         [10.0000, 10.0000, 10.0000, 10.0000, 10.0000, 10.0000, 10.0000,
          10.0000, 10.0000, 10.0000, 10.0000, 10.0000],
         [13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333, 13.3333,
          13.3333, 13.3333, 13.3333, 13.3333, 13.3333],
         [16.6667, 16.6667, 16.6667, 16.6667, 16.6667, 16.6667, 16.6667,
          16.6667, 16.6667, 16.6667, 16.6667, 16.6667],
         [20.0000, 20.0000, 20.0000, 20.0000, 20.0000, 20.0000, 20.0000,
          20.0000, 20.0000, 20.0000, 20.0000, 20.0000]]])
==============>>>>>>>>>>>>>>>ds
tensor([[[ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.],
         [ 5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.,  5.]],

        [[10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.],
         [10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10., 10.]]])
==============>>>>>>>>>>>>>>>frustum
tensor([[[[ 0.0000,  0.0000,  5.0000],
          [ 3.1818,  0.0000,  5.0000],
          [ 6.3636,  0.0000,  5.0000],
          [ 9.5455,  0.0000,  5.0000],
          [12.7273,  0.0000,  5.0000],
          [15.9091,  0.0000,  5.0000],
          [19.0909,  0.0000,  5.0000],
          [22.2727,  0.0000,  5.0000],
          [25.4545,  0.0000,  5.0000],
          [28.6364,  0.0000,  5.0000],
          [31.8182,  0.0000,  5.0000],
          [35.0000,  0.0000,  5.0000]],

         [[ 0.0000,  3.3333,  5.0000],
          [ 3.1818,  3.3333,  5.0000],
          [ 6.3636,  3.3333,  5.0000],
          [ 9.5455,  3.3333,  5.0000],
          [12.7273,  3.3333,  5.0000],
          [15.9091,  3.3333,  5.0000],
          [19.0909,  3.3333,  5.0000],
          [22.2727,  3.3333,  5.0000],
          [25.4545,  3.3333,  5.0000],
          [28.6364,  3.3333,  5.0000],
          [31.8182,  3.3333,  5.0000],
          [35.0000,  3.3333,  5.0000]],

         [[ 0.0000,  6.6667,  5.0000],
          [ 3.1818,  6.6667,  5.0000],
          [ 6.3636,  6.6667,  5.0000],
          [ 9.5455,  6.6667,  5.0000],
          [12.7273,  6.6667,  5.0000],
          [15.9091,  6.6667,  5.0000],
          [19.0909,  6.6667,  5.0000],
          [22.2727,  6.6667,  5.0000],
          [25.4545,  6.6667,  5.0000],
          [28.6364,  6.6667,  5.0000],
          [31.8182,  6.6667,  5.0000],
          [35.0000,  6.6667,  5.0000]],

         [[ 0.0000, 10.0000,  5.0000],
          [ 3.1818, 10.0000,  5.0000],
          [ 6.3636, 10.0000,  5.0000],
          [ 9.5455, 10.0000,  5.0000],
          [12.7273, 10.0000,  5.0000],
          [15.9091, 10.0000,  5.0000],
          [19.0909, 10.0000,  5.0000],
          [22.2727, 10.0000,  5.0000],
          [25.4545, 10.0000,  5.0000],
          [28.6364, 10.0000,  5.0000],
          [31.8182, 10.0000,  5.0000],
          [35.0000, 10.0000,  5.0000]],

         [[ 0.0000, 13.3333,  5.0000],
          [ 3.1818, 13.3333,  5.0000],
          [ 6.3636, 13.3333,  5.0000],
          [ 9.5455, 13.3333,  5.0000],
          [12.7273, 13.3333,  5.0000],
          [15.9091, 13.3333,  5.0000],
          [19.0909, 13.3333,  5.0000],
          [22.2727, 13.3333,  5.0000],
          [25.4545, 13.3333,  5.0000],
          [28.6364, 13.3333,  5.0000],
          [31.8182, 13.3333,  5.0000],
          [35.0000, 13.3333,  5.0000]],

         [[ 0.0000, 16.6667,  5.0000],
          [ 3.1818, 16.6667,  5.0000],
          [ 6.3636, 16.6667,  5.0000],
          [ 9.5455, 16.6667,  5.0000],
          [12.7273, 16.6667,  5.0000],
          [15.9091, 16.6667,  5.0000],
          [19.0909, 16.6667,  5.0000],
          [22.2727, 16.6667,  5.0000],
          [25.4545, 16.6667,  5.0000],
          [28.6364, 16.6667,  5.0000],
          [31.8182, 16.6667,  5.0000],
          [35.0000, 16.6667,  5.0000]],

         [[ 0.0000, 20.0000,  5.0000],
          [ 3.1818, 20.0000,  5.0000],
          [ 6.3636, 20.0000,  5.0000],
          [ 9.5455, 20.0000,  5.0000],
          [12.7273, 20.0000,  5.0000],
          [15.9091, 20.0000,  5.0000],
          [19.0909, 20.0000,  5.0000],
          [22.2727, 20.0000,  5.0000],
          [25.4545, 20.0000,  5.0000],
          [28.6364, 20.0000,  5.0000],
          [31.8182, 20.0000,  5.0000],
          [35.0000, 20.0000,  5.0000]]],


        [[[ 0.0000,  0.0000, 10.0000],
          [ 3.1818,  0.0000, 10.0000],
          [ 6.3636,  0.0000, 10.0000],
          [ 9.5455,  0.0000, 10.0000],
          [12.7273,  0.0000, 10.0000],
          [15.9091,  0.0000, 10.0000],
          [19.0909,  0.0000, 10.0000],
          [22.2727,  0.0000, 10.0000],
          [25.4545,  0.0000, 10.0000],
          [28.6364,  0.0000, 10.0000],
          [31.8182,  0.0000, 10.0000],
          [35.0000,  0.0000, 10.0000]],

         [[ 0.0000,  3.3333, 10.0000],
          [ 3.1818,  3.3333, 10.0000],
          [ 6.3636,  3.3333, 10.0000],
          [ 9.5455,  3.3333, 10.0000],
          [12.7273,  3.3333, 10.0000],
          [15.9091,  3.3333, 10.0000],
          [19.0909,  3.3333, 10.0000],
          [22.2727,  3.3333, 10.0000],
          [25.4545,  3.3333, 10.0000],
          [28.6364,  3.3333, 10.0000],
          [31.8182,  3.3333, 10.0000],
          [35.0000,  3.3333, 10.0000]],

         [[ 0.0000,  6.6667, 10.0000],
          [ 3.1818,  6.6667, 10.0000],
          [ 6.3636,  6.6667, 10.0000],
          [ 9.5455,  6.6667, 10.0000],
          [12.7273,  6.6667, 10.0000],
          [15.9091,  6.6667, 10.0000],
          [19.0909,  6.6667, 10.0000],
          [22.2727,  6.6667, 10.0000],
          [25.4545,  6.6667, 10.0000],
          [28.6364,  6.6667, 10.0000],
          [31.8182,  6.6667, 10.0000],
          [35.0000,  6.6667, 10.0000]],

         [[ 0.0000, 10.0000, 10.0000],
          [ 3.1818, 10.0000, 10.0000],
          [ 6.3636, 10.0000, 10.0000],
          [ 9.5455, 10.0000, 10.0000],
          [12.7273, 10.0000, 10.0000],
          [15.9091, 10.0000, 10.0000],
          [19.0909, 10.0000, 10.0000],
          [22.2727, 10.0000, 10.0000],
          [25.4545, 10.0000, 10.0000],
          [28.6364, 10.0000, 10.0000],
          [31.8182, 10.0000, 10.0000],
          [35.0000, 10.0000, 10.0000]],

         [[ 0.0000, 13.3333, 10.0000],
          [ 3.1818, 13.3333, 10.0000],
          [ 6.3636, 13.3333, 10.0000],
          [ 9.5455, 13.3333, 10.0000],
          [12.7273, 13.3333, 10.0000],
          [15.9091, 13.3333, 10.0000],
          [19.0909, 13.3333, 10.0000],
          [22.2727, 13.3333, 10.0000],
          [25.4545, 13.3333, 10.0000],
          [28.6364, 13.3333, 10.0000],
          [31.8182, 13.3333, 10.0000],
          [35.0000, 13.3333, 10.0000]],

         [[ 0.0000, 16.6667, 10.0000],
          [ 3.1818, 16.6667, 10.0000],
          [ 6.3636, 16.6667, 10.0000],
          [ 9.5455, 16.6667, 10.0000],
          [12.7273, 16.6667, 10.0000],
          [15.9091, 16.6667, 10.0000],
          [19.0909, 16.6667, 10.0000],
          [22.2727, 16.6667, 10.0000],
          [25.4545, 16.6667, 10.0000],
          [28.6364, 16.6667, 10.0000],
          [31.8182, 16.6667, 10.0000],
          [35.0000, 16.6667, 10.0000]],

         [[ 0.0000, 20.0000, 10.0000],
          [ 3.1818, 20.0000, 10.0000],
          [ 6.3636, 20.0000, 10.0000],
          [ 9.5455, 20.0000, 10.0000],
          [12.7273, 20.0000, 10.0000],
          [15.9091, 20.0000, 10.0000],
          [19.0909, 20.0000, 10.0000],
          [22.2727, 20.0000, 10.0000],
          [25.4545, 20.0000, 10.0000],
          [28.6364, 20.0000, 10.0000],
          [31.8182, 20.0000, 10.0000],
          [35.0000, 20.0000, 10.0000]]]])

Process finished with exit code 0

标签:10,5.0000,10.0000,6.6667,lss,16.6667,0.0000
From: https://www.cnblogs.com/yanghailin/p/17452610.html

相关文章