def initialize(self): self.bn0 = M.BatchNorm() self.c1 = M.ConvLayer(7, 64, stride=2, activation=M.PARAM_RELU, batch_norm=True, usebias=False) self.pool = M.MaxPool2D(3, 2) self.stage1 = Stage(64, num_units=3, stride=1) self.stage2 = Stage(128, num_units=4, stride=2) self.stage3 = Stage(256, num_units=6, stride=2) self.stage4 = Stage(512, num_units=3, stride=2) self.bn1 = M.BatchNorm() self.act = M.Activation(M.PARAM_RELU) self.ssh_c3_lateral = M.ConvLayer(1, 256, batch_norm=True, activation=M.PARAM_RELU) self.det3 = DETHead() self.head32 = RegressHead() self.ssh_c2_lateral = M.ConvLayer(1, 256, batch_norm=True, activation=M.PARAM_RELU) self.ssh_c3_upsampling = M.NNUpSample(2) self.ssh_c2_aggr = M.ConvLayer(3, 256, batch_norm=True, activation=M.PARAM_RELU) self.det2 = DETHead() self.head16 = RegressHead() self.ssh_m1_red_conv = M.ConvLayer(1, 256, batch_norm=True, activation=M.PARAM_RELU) self.ssh_c2_upsampling = M.NNUpSample(2) self.ssh_c1_aggr = M.ConvLayer(3, 256, batch_norm=True, activation=M.PARAM_RELU) self.det1 = DETHead() self.head8 = RegressHead()
def initialize(self, channel_list, blocknum_list): self.c1 = M.ConvLayer(7, channel_list[0], stride=2, usebias=False, batch_norm=True, activation=M.PARAM_RELU) self.maxpool = M.MaxPool2D(3, 2) self.stage1 = Stage(channel_list[1], blocknum_list[0], stride=1) self.stage2 = Stage(channel_list[2], blocknum_list[1], stride=2) self.stage3 = Stage(channel_list[3], blocknum_list[2], stride=2) self.stage4 = Stage(channel_list[4], blocknum_list[3], stride=2) self.fc1 = M.Dense(1000)
def top_k(hmap, tags): pool = M.MaxPool2D(config.nms_kernel) hmap_m = pool(hmap) hmap_m = torch.eq(hmap_m, hmap).float() hmap = hmap_m * hmap bsize, num_pts, h, w = hmap.shape hmap = hmap.view(bsize, num_pts, h * w) tags = tags.view(bsize, num_pts, h * w, -1) val, ind = hmap.topk(config.max_inst, dim=2) ind_expanded = ind.unsqueeze(-1).expand(-1, -1, -1, tags.shape[-1]) tagk = torch.gather(tags, 2, ind_expanded) x = ind % w y = (ind / w).long() indk = torch.stack((x, y), dim=3) vals, indk, tagk = val[0], indk[0], tagk[0] return vals, indk, tagk
def initialize(self, stride, bn=False): self.p = M.MaxPool2D(3, stride)
def initialize(self, stride, bn=False): self.bn = bn self.p = M.MaxPool2D(3, stride) if self.bn: self.batch_norm = M.BatchNorm()